To facilitate a marketplace on the FNCY blockchain to pull in off-chain metadata for ERC721 assets, the NFT contract will need to return a URI where the metadata can be found. To find this URI, the tokenURI method in ERC721 and the uri method in ERC1155 is used to track your NFT. You should implement the function in the 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 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.
Metadata Structure
Marketplaces on FNCY Blockchain support metadata that is structured according to the official ERC721 metadata standard. Additionally, several properties for your items are supported, giving you all the sorting and filtering capabilities on FNCY Blockchain Marketplaces. The below metadata structure, allows the FNCY Blockchain Marketplace to read and display the details about the assets which your NFTs represent.
A human-readable description of the item. Markdown is supported. Max 500 characters.
image
This is the URL to the image of the item. Can be just about any type of image. A 350 x 350 image is recommended.
animation_url
This is the URL to a multi-media attachment for the item. The file extensions GLTF, GLB, WEBM, MP4, M4V, OGV, and OGG are supported, along with the audio-only extensions MP3, WAV, and OGA.
animation_type
This is the file format of the multi-media attachment provided from animation_url.
external_url
This is the URL that will appear below the asset's image on the marketplace and will allow users to leave the marketplace and view the item on your site.
attributes
These are the attributes for the item to describe the detail of the NFT. (see array below)
Attributes
To present NFT traits, include the following array in the metadata:
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 a numeric value should be displayed. For string traits, you don't have to worry about display_type. All traits included in the attributes will be displayed in Attribute. 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 attribute.
Numeric Traits
There are 3 supported options for display_type: number will show the value in pure number, boost_number allows you to show the number with Plus or Minus symbol, and boost_percentage is similar to boost_number but will show a percent sign behind the number.
Date
Marketplace also supports date traits in datedisplay_type. Pass in a unix timestamp as the value.
Next, we install a development tool for deployment. For this tutorial, we will use Truffle, but we could use any other tools, such as Buidler, Remix, or OpenZeppelin CLI.
$ npm i truffle
Getting the Contract Artifacts
We will setup our Solidity project using truffle init to create a contracts directory and configuration to connect to a network.
We are going to use Preset ERC721PresetMinterPauserAutoId which is an ERC721, which is a preset that can be minted (with auto token ID and metadata URI), paused, and burned.
The preset contracts have already been compiled, so we only need to copy the artifacts to the build/contracts directory.
We can send a transaction to mint tokens to a given account, from an account with the minter role. In our case, we are minting from the account which deployed the token, which is given the minter role.
We will mint 1 NFT with token ID 1. Specify the address that you want to be the token holder (0xc7e4bBc4269fdC62F879834E363173aeE7895F45 is a test account)