Metadata

Intro

The TRAIT Blockchain possesses a common infrastructure for a variety of applications and a large number of players. For stable and fast operation, we strive to store the minimum amount of data on the blockchain.

From a simplified perspective in relation to on-chain assets, the TRAIT Blockchain stores the following basic data:

  • tuples for fungible tokens: fungible token ID, owner blockchain address, balance;

  • tuples for NFTs: collection ID, NFT ID, owner blockchain address;

This information is sufficient for storing and transferring on-chain assets between blockchain addresses. But for most applications to function, additional information is needed which we call "metadata". TRAIT establishes an agreement on how such data is generated, stored, and transmitted between applications.

Metadata explained

Metadata is a JSON file containing all the data and links required by applications to work correctly with this on-chain entity. The metadata may contain the name of an asset, a link to an image, a set of tags, a link to another on-chain asset, and any other data needed by engineers and applications. When interacting with an on-chain entity, the application recognizes a link to the entity's metadata, downloads the metadata, and uses it as needed.

For example, the TRAIT Wallet for players downloads metadata for NFTs from which it learns the names of the tokens, links to media content, and NFT attributes. Then this data is displayed to the players on the phone screen.

Metadata can be created for all main on-chain entities: NFTs, NFT Collections, Fungible tokens, and AppAgents.

As a rule, metadata is stored on the game studio server or in a Content Delivery Network (CDN) or in the services like AWS S3.

The game studio has full control over the metadata of its on-chain entities. For example, it can update the NFT attributes to reflect changes in the balance of the game. Or it can update media content associated with NFT or Fungible token. Data from metadata can be added or removed so that the on-chain entity can be used by some new application or become compliant with new metadata requirements. For all of these operations, it is enough to update the JSON file with metadata on the server.

Structure of metadata

Let's consider an example of metadata of a NFT.

{
    "metadata_id": "2300-15980",
    "title": "Metadata of NFT item Long Sword",
    "description": "...",
    "traits": {
        "named": {
            "name": "Long Sword"
        },
        "tech.trait.wallet.square_icon": {
            "image_uri": "https://github.com/traittech/traits-registry/blob/main/examples/trait-logo-150.svg"
        },
        "tech.trait.wallet.nft_token_cover_image": {
            "image_uri": "https://github.com/traittech/traits-registry/blob/main/examples/trait-logo-1920.svg"
        },
        "tech.trait.wallet.nft_token_attributes": {
            "attributes": [
                {
                    "name": "Attack",
                    "display_type": "number",
                    "value": 73
                },
                {
                    "name": "Critical hit",
                    "display_type": "percentage",
                    "value": 52
                },
                {
                    "name": "Engraving",
                    "display_type": "string",
                    "value": "With honor"
                }
            ]
        }
    }
}

Properties metadata_id, title, description have technical nature. In this example metadata_id contains ID of NFT token annotated with this metadata (NFT collection ID 2300and NFT item ID 15980). title and description help engineers and any interested party to identify and understand the metadata document.

Property traits is where all relevant information about the NFT token is stored. Sub-keys named & tech.trait.wallet.square_icon & etc are the unique IDs of traits. This particular metadata supports several traits:

  • named - provides name of the object;

  • tech.trait.wallet.square_icon & tech.trait.wallet.nft_token_cover_image - provide images displayed by the TRAIT wallet;

  • tech.trait.wallet.nft_token_attributes - provides attributes of the NFT displayed by the TRAIT wallet;

This JSON document, together with linked images, allows TRAIT wallet to correctly display an NFT item. Adding more traits to the doc will bring more features to the corresponding NFT. Read about it in the next section.

Last updated