Summary
When you create a new fungible or non-fungible token, you have the ability to add metadata. It’s common to add metadata for NFTs, but also fungible tokens. The biggest problem with metadata is that it’s often unstructured or doesn’t follow a set of guidelines. Therefore, Hedera has developed the “Token Metadata JSON Schema V2” for developers and creators who want to structure their metadata in an organized way. The biggest benefit of using this community-accepted standard is that most of the tooling on the Hedera network can scrape and interpret your metadata, like NFT explorers listing rarity attributes based on your metadata.Prerequisites
We recommend you complete one of the two tutorials below that teach you how to create a fungible or non-fungible token on the Hedera network.Create And Transfer Your First Nft
Create And Transfer Your First Fungible Token
Table of Contents
How do you connect metadata to a token?
It’s essential to understand that the token metadata JSON schema V2 requires you to store metadata using a storage solution, centralized or decentralized, such as IPFS or Arweave. When creating a non-fungible token using the Hedera Token Service, you set the metadata value to the metadata JSON file to define your NFT, wherever it’s stored. This technique allows you to connect the metadata to the token created on the Hedera network. The “memo” or “symbol” fields are not allowed on the NFT. An excerpt from the NFT minting tutorial shows this connection when minting a new NFT.What does the Token Metadata JSON schema V2 look like?
First of all, you can find the full reference implementation of this JSON schema here:- Hedera Improvement Proposals GitHub Repository
- NFT.Storage (gateway link)
- IPFS: ipfs://bafkreidcsqzr5su356thecwuyzrhsgekfdsqzuyuqxtsu4vh7oc34iv5oy
Required fields:
- name, type, and image
The schema defines three required fields:
- name: Full name of the NFT
- type: MIME type for the image
- image: A URI pointing to an image (decentralized or centralized storage).
image field can both serve as a preview or full-resolution image for your NFT to ensure cross-platform compatibility. The image field will be displayed in wallets and marketplaces by default.Creators are recommended to point to a thumbnail in the image field and put the high-resolution image in the files array with the is_default_file boolean set to indicate that this file represents the default image for the NFT. (This is shown in the next section)Here’s a small example of an implementation.Optional fields:
- files
- properties
- attributes
- localization
- description, creator, creatorDID, checksum, and format
The
files field represents an array containing file objects. For collectible NFTs, the files array allows you to store the high-resolution image of your NFT. However, you can also use this field for multi-file NFTs. Each file object requires a URI and type.It’s recommended to use the is_default_file field to indicate which file is the main file for your NFT. Besides that, the files array allows you to upload or link file-specific metadata. This allows you to nest files indefinitely.Putting things together:
- Full schema implementation
This is what a full Token Metadata JSON Schema V2 specification looks like.
How do you verify your token metadata is correct?
When you create token metadata for the first time, you want to verify your metadata against the Token Metadata JSON Schema V2. To help you, Hedera has created an NFT utilities SDK (only for JavaScript) to verify your metadata against the JSON Schema V2. You can install the package using Yarn or NPM.validator function that accepts your metadata as a JSON object and the schema version against which you want to verify the metadata (2.0.0). Here’s the code.
percentage display_type in the attributes field, and you have defined a custom field called imagePreview on the root of the metadata object, which is not allowed (use the properties field).
Want to learn more about token metadata?
Here’s a video about how crucial structuring your token metadata is and how to do it according to Token Metadata JSON Schema V2.
You can find examples in this blog post in the section “Token Metadata V2 NFT Examples”. If you still have questions, reach out on Discord or ask it on StackOverflow.
Besides that, you can read up on the full implementation of token metadata in the Hedera Improvement Proposals GitHub Repository under HIP-412.