Skip to content

implement generateId #10

@nikgraf

Description

@nikgraf

Probably best if we follow the GRC-20 spec:

All IDs must be globally unique and 22 characters using Base58 encoding. They should be created using the UUID4 standard and stripping out the dashes (bringing the length from 36 bytes to 32 bytes) and then Base58 encoding. If an entity is coming from a system that already has globally unique IDs of arbitrary length, they can be deterministically converted into valid globally unique 22 character IDs by taking an md5 hash of the string, seeding that into a UUID4 generator, stripping the dashes and Base58 encoding. IDs must be randomly generated and not be altered to contain any identifiable strings in order to prevent collisions.

Example ID: Gw9uTVTnJdhtczyuzBkL3X

Update the generatedId function to strip the - and base58 encode it.

This should work on Node, browser and ReactNative environment. Ideally we don't have to use a dependency, but if we do it should be a very trustworthy one.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions