Contract metadata โ
:::
info Contract metadata should not be confused with token metadata.
:::
The contract's metadata contains general descriptions of the contract and the offchain-views.
It is stored into a separate JSON file stored on IPFS (or any https accessible address). A link to it is stored in the metadata
bigmap.
The FA2 library helps you generate the contract metadata JSON file. You can do it by giving a base_metadata
dictionary to the __init__
of the base class.
Example:
sp.add_compilation_target(
"Fa2Nft_tokens",
ExampleFa2Nft(
metadata = sp.utils.metadata_of_url("http://example.com"),
metadata_base = {
"version": "1.0.0",
"description" : "This implements FA2 (TZIP-012) using SmartPy.",
"interfaces": ["TZIP-012", "TZIP-016"],
"authors": ["SmartPy <https://legacy.smartpy.io/#contact>"],
"homepage": "https://legacy.smartpy.io/ide?template=FA2.py",
"source": {
"tools": ["SmartPy"],
"location": "https://gitlab.com/SmartPy/smartpy/-/raw/master/python/templates/FA2.py"
},
"permissions": {
"receiver": "owner-no-hook",
"sender": "owner-no-hook"
}
}
)
)
Your JSON file will be available under the metadata
tab (IDE) or in the generated files under the name "metadata_base" (CLI). It contains your dictionary augmented by the views and the name of the operator permission (i.e. self.policy.name
).
You can upload this file on IPFS or any server.
The link to this file is given to your base class: metadata = sp.utils.metadata_of_url("http://example.com")
See more info about contract metadata in the contract metadata guide.