Token metadata β
INFO
Token metadata should not be confused with contract metadata.
Introduction β
Token metadata describe one token (e.g. name, thumbnail...) of a FA2 contract. It provides information that is not directly used for a contract's operation. If a FA2 contract contains 150 NFTs, it will contain 150 token metadata map.
Token metadata are stored in a FA2 contract or in a in JSON files stored outside of the blockchain and referenced in the contract.
If you store token metadata outside of the blockchain you'll have to upload them by yourself. We provide some explanations on how to do it.
Usage β
Token-specific metadata is stored/presented as a Michelson value of type (map string bytes)
.
A few of the keys are reserved and predefined by TZIP-12:
""
(empty-string): should correspond to a URI schemes which points to a JSON representation of the token metadata."name"
: should be a UTF-8 string giving a βdisplay nameβ to the token."symbol"
: should be a UTF-8 string for the short identifier of the token (e.g. XTZ, EUR,Β β¦)."decimals"
: should be an integer (converted to a UTF-8 string in decimal) which defines the position of the decimal point in token balances for display purposes.
The library gives an helper: make_metadata
that prepare the sp.TMap(sp.TString, sp.TBytes)
.
Example:
example_md = FA2.make_metadata(
decimals = 0,
name = "Example FA2",
symbol = "DFA2" )
If you need more values in the metadata, you can create your own map by hands. The previous example is equivalent to:
sp.map(l = {
"decimals" : sp.utils.bytes_of_string("%d" % 0),
"name" : sp.utils.bytes_of_string("Example FA2"),
"symbol" : sp.utils.bytes_of_string("DFA2")
}
Advanced media β
When using NFT you often want to attach an image, a list of author and a lot of information about your token.
The corresponding keys and values are described in TZIP-16. As the content start being big, the convenient way is to add all inside a JSON file, upload it on IPFS and reference it inside the map using URI schemes.
See the URI schemes guide for more information.