By providing asset metadata, applications like NFTify can bring in rich data for digital assets and display them in-app. Digital assets on a given smart contract are typically represented solely by a unique identifier (e.g., the token_id
in ERC721), so metadata allows these assets to have additional properties, such as a name, description, date, and image.
1. Implementing Token URI
For NFTify to pull 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 at the tokenURI
method in a contract.
/**
* @dev Returns an URI for a given token ID
*/
function tokenURI(uint256 _tokenId) public view returns (string) {
return Strings.strConcat(
baseTokenURI(),
Strings.uint2str(_tokenId)
);
}
The tokenURI
function in your ERC721 or the uri
function in your ERC1155 contract should return an HTTP or IPFS URL, such as https://metadata.nftify.network/ipfs/43386991863816464903773437711726767830435150118599033599737883779213817849333. When queried, this URL should in turn return a JSON blob of data with the metadata for your token.
2. Using Ownable
For developers to set up contracts on NFTify automatically.
Read more about OpenZeppelin contracts here.
3. Metadata Structure
NFTify supports metadata that is structured according to the official ERC721 metadata standard.
Furthermore, we support various other properties that allow for multimedia attachments - including audio, video, and 3D models - as well as interactive traits for your items, giving you all the sorting and filtering capabilities on the NFTify marketplace.
Here's an example of metadata for a NFT on NFTify.
{
"name":"GRSE-R-3-2021",
"description":"Rare Card",
"image":"https://data.nftify.network/ipfs/QmXYTfp61bxYcSEFGWm7qEr6qMYdkx7YocBG85th6mQPA9",
"external_url":"https://wolflexnft.nftify.network/nft/grser32021",
"attributes":[],
"artist":"0x45d1A075c51186291a2eB914cbC7B0efe17BDDe8"
}
Here is how each of these properties work:
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. We recommend using a 350 x 350 image. |
external_url | This is the URL that will appear below the asset's image on NFTify and will allow users to leave NFTify and view the item on your site. |
description |
A human readable description of the item. Markdown is supported. |
name | Name of the item. |
attributes | These are the attributes for the item, which will show up on the page for the item. (see below) |
animation_url |
A URL to a multi-media attachment for the item. The file extensions GLB, WEBM, MP4, and OGG are supported, along with the audio-only extensions MP3 and WAV. Animation_url also supports HTML pages, allowing you to build rich experiences and interactive NFTs using JavaScript canvas, WebGL, and more. Scripts and relative paths within the HTML page are now supported. However, access to browser extensions is not supported. |
4. Attributes
We also allow you to add custom "attributes" to your metadata that will appear beneath each of your assets to give your items a little more pizazz.
To generate those attributes, the following array of attributes was included in the metadata:
...
{
"attributes": [
{
"trait_type": "Base",
"value": "Hamster"
},
{
"trait_type": "Eyes",
"value": "Small"
},
{
"trait_type": "Size",
"value": "Small"
},
{
"trait_type": "Stamina",
"value": 3
},
{
"display_type": "boost_number",
"trait_type": "Power",
"value": 3
},
{
"display_type": "boost_percentage",
"trait_type": "Stamina",
"value": 10
},
{
"display_type": "number",
"trait_type": "Generation",
"value": 3
}
]
}
Here trait_type
is the name of the trait, value
is the value of the trait, and display_type
is a field indicating how you would like it to be displayed. For string
traits, you don't have to worry about display_type
.
4.1. Numeric Traits
For numeric traits, NFTify currently supports three options: number
, boost_percentage
, and boost_number
(similar to boost_percentage
but doesn't show a percent sign). If you pass in a value
that's a number and you don't set a display_type
, the trait will appear in the Levels section.
Adding an optional max_value
sets a ceiling for a numerical trait's possible values. It defaults to the maximum that NFTify has seen so far on the assets on your contract. If you set a max_value
, make sure not to pass in a higher value
.
4.2. Date Traits
NFTify also supports a date
display_type
. Traits of this type will appear below "Boosts." Pass in a unix timestamp as the value.
{
"display_type": "date",
"trait_type": "birthday",
"value": 1637033050
}
If you don't want to have a trait_type
for a particular trait, you can include just a value in the trait and it will be set as a generic property. For example,
{
"value": "Happy"
}
5. Attribute guidelines
When coming up with your attributes, you should include string attributes as strings (remember the quotes), and numeric properties as either floats or integers so that NFTify can display them properly. String properties should be human-readable strings.
6. IPFS
NFTify supports the storage of NFT metadata in decentralized file networks like IPFS, so that they can’t be modified by a central party.
If you use IPFS to host your metadata, your URL should be in the format ipfs://<hash>
. For example, ipfs://QmTy8w65yBXgyfG2ZBg5TrfB2hPjrDQH3RCQFJGkARStJb
. If you plan to store on IPFS, we recommend Pinata for easily storing data. Here's a tutorial by Chainlink for getting started: https://blog.chain.link/build-deploy-and-sell-your-own-dynamic-nft/.
Comments
0 comments
Please sign in to leave a comment.