How to prepare an entry for the registry (NA policy script) - mlabs-haskell/cardano-token-registry GitHub Wiki
Pre-Requisites
To register native token mappings, it is recommended to have pre-existing knowledge about Cardano native assets. Start by reading through the developer guide on Native Assets.
After creating a Cardano native asset you will need the following to proceed with the steps to generate a mapping for the registry:
- The monetary policy script for your native asset (optional for Plutus Smart-Contracts).
- The assetName associated with the monetary policy script.
- The policyId of the monetary policy script.
- The private key/s used to define your asset policy.
- Install
offchain-metadata-tools
(see offchain-metadata-tools).
With Plutus Smart-Contracts the policy script is optional, instead of being a hash of the policy.json
monetary policy script policyId is defined to be the hash (blake2b-224) of the serialized Plutus script itself.
Step 1: Generate the 'subject'
To create a new mapping, you must first obtain your metadata subject. The subject is defined as the concatenation of the base16-encoded policyId and base16-encoded assetName of your asset. In case your assetName is empty, then the policyId is your subject.
For this example, we will consider the following native asset:
baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f.myassetname
- Base16 encode your assetName:
$ echo -n "myassetname" | xxd -ps
6d7961737365746e616d65
- Concatenate the policyId with the base16-encoded assetName to obtain the 'subject' for your entry:
baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f6d7961737365746e616d65
Step 2: Prepare a draft entry
- Initialise a new draft entry for the subject using
token-metadata-creator
token-metadata-creator entry --init baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f6d7961737365746e616d65
This creates a draft JSON file named after your subject.
Step 3: Add required fields
Plutus Smart-Contracts may not be linked to signing keys in which case --policy
flag is not required.
token-metadata-creator entry baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f6d7961737365746e616d65 \
--name "My Gaming Token" \
--description "A currency for the Metaverse." \
--policy policy.json
Where policy.json
is the monetary policy script file that hashes to the policyId.
Step 4: Add optional fields
token-metadata-creator entry baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f6d7961737365746e616d65 \
--ticker "TKN" \
--url "https://finalfantasy.fandom.com/wiki/Gil" \
--logo "icon.png" \
--decimals 4
Step 5: Sign your metadata
Each metadata item must be signed with the key/s used to define your asset policy if one is available. For this example we assume only a single signing key is required to validate the monetary policy script and that all metadata fields will be signed at once with the signing key file. Please refer to offchain-metadata-tools for more granular options.
token-metadata-creator entry baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f6d7961737365746e616d65 -a policy.skey
Step 6: Finalize your mapping
This will run some additional validations on your submission and check that it is considered valid.
token-metadata-creator entry baa836fef09cb35e180fce4b55ded152907af1e2c840ed5218776f2f6d7961737365746e616d65 --finalize
Your finalized metadata file is now ready to submit to the cardano-token-registry. Follow these steps to proceed with the submission.