MetaData Standard

Providing asset metadata allows applications to pull in rich data for digital assets and easily display them in-app.

Implementing token URI

For Tabi 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 closely at the tokenURI method in the Creature 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. When queried, this URL should in turn return a JSON blob of data with the metadata for your token.

See the section on IPFS and Arweave below for how to handle decentralized metadata URIs.

Metadata structure

{
  "description": "Meebit #7241", 
  "image": "http://meebits.larvalabs.com/meebitimages/characterimage?index=7241&type=full&imageType=jpg", 
  "name": "Meebit",
  "attributes": [ ... ], 
}

Here's how each of these properties work:

Attributes

To give your items a little more pizazz, we also allow you to add custom "attributes" to your metadata that will show up underneath each of your assets.

To generate those attributes, the following array of attributes was included in the metadata:

...
{
"attributes": [
    {
      "trait_type": "Base", 
      "value": "Starfish"
    }, 
    {
      "trait_type": "Eyes", 
      "value": "Big"
    }, 
    {
      "trait_type": "Mouth", 
      "value": "Surprised"
    }, 
    {
      "trait_type": "Level", 
      "value": 5
    }, 
    {
      "trait_type": "Stamina", 
      "value": 1.4
    }, 
    {
      "trait_type": "Personality", 
      "value": "Sad"
    }, 
    {
      "display_type": "boost_number", 
      "trait_type": "Aqua Power", 
      "value": 40
    }, 
    {
      "display_type": "boost_percentage", 
      "trait_type": "Stamina Increase", 
      "value": 10
    }, 
    {
      "display_type": "number", 
      "trait_type": "Generation", 
      "value": 2
    }
  ]
}

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.

Numeric Traits

For numeric traits, Tabi currently supports three different options, number (lower right in the image below), boost_percentage (lower left in the image above), 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 Rankings section (top right in the image above).

Adding an optional max_value sets a ceiling for a numerical trait's possible values. It defaults to the maximum that Tabi 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.

IPFS and Arweave URIs

Tabi supports the storage of NFT metadata in decentralized file networks, 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/.

Arweave's equivalent is ar://<hash>. For example, ar://jK9sR4OrYvODj7PD3czIAyNJalub0-vdV_JAg1NqQ-o.

Freezing Metadata

You can indicate to Tabi that an NFT's metadata is no longer changeable by anyone (in other words, it is "frozen") by emitting this event from the smart contract:

event PermanentURI(string _value, uint256 indexed _id);

Contact us if you'd like to mark an entire smart contract as frozen.

Last updated