Deploy a NFT
How to add rich metadata to your ERC721 or ERC1155 NFTs
Implementing token URI
For pulling in off-chain metadata for ERC721 and ERC1155 assets, your contract will need to return a URI where we can find the metadata. To find this URI, we use the tokenURI method in ERC721 and the uri method in ERC1155. First, let's look closely at the tokenURI method in the Creature contract.
ERC721
ref: eip-721
ERC1155
ref: eip-1155
ERC1155 Metadata_URI
The URI value allows for ID substitution by clients. If the string {id} exists in any URI, clients MUST replace this with the actual token ID in hexadecimal form. This allows for a large number of tokens to use the same on-chain string by defining a URI once, for that large number of tokens. The string format of the substituted hexadecimal ID MUST be lowercase alphanumeric: [0-9a-f] with no 0x prefix. The string format of the substituted hexadecimal ID MUST be leading zero padded to 64 hex characters length if necessary. Example of such a URI: https://token-cdn-domain/{id}.json would be replaced with https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json. if the client is referring to token ID 314592/0x4CCE0.
Metadata
The tokenURI function in your ERC721 or the uri function in your ERC1155 contract should return an HTTP or IPFS URL. When queried, this URL should in turn return a JSON blob of data with the metadata for your token.
Here's main property definition
name
Name of the item.
image
This is the URL to the image of the item. Can be just about any type of image , and can be IPFS URLs or paths. If you use IPFS to host your metadata, your URL can be in the format ipfs://{hash}.
creator
creator wallet address
description
A human readable description of the item. Markdown is supported.
marketplace
marketplace if necessary
Last updated