Advanced Metadata Guide

Learn Advanced Metadata Parameters and how to use it while interacting with your Enjin Tokens.
If you wish to create your own Metadata file, you will need to save it as a .json file.
Once you have your .json file uploaded with public read access, you can make the request to set the item URI (Uniform Resource Identifier).
Here is an example of a simple metadata schema:
{
"name": "item_name",
"description": "Description line 1.\nDescription line2.",
"image": "/image.jpg"
}
For more information on how to create a more robust JSON file, visit the ERC-1155 Github.

Specific Metadata URI

Any token ID may have a metadata URI that can be retrieved by calling uri(_id) on the ERC-1155 contract.
If an individual Non-Fungible token ID has a metadata URI defined, client apps should use this URI. If not defined, client apps should call uri(_id) on the base token id to retrieve the Default URI for the entire set of Non-Fungible tokens.

Default URI

A Non-Fungible token that defines a Default URI in its base token has the option of using an {id} placeholder in the URI itself. This will get replaced with the distinct ID when accessing NFTs.
Example:
yoursite.com/{id}.json -> yoursite.com/bd4818c04f57a2ebc473d74ee06d6e0600000000000000000000000000000001.json

Images

If the Default URI contains an image property that in turn contains the {id} placeholder, the image URL will be used as the default image for all tokens of this type.
yoursite.com/images/{id}.jpg -> yoursite.com/images/bd4818c04f57a2ebc473d74ee06d6e0600000000000000000000000000000001.jpg
The image property can also be a static URI without the placeholder, as desired.

Asset backgrounds

If you opt for generating your own metadata, in the JSON you can set various coloured backgrounds for your assets to display in the Enjin Wallet app.
To do this, you will need to set the color: attribute in your JSON file, such as the following example:
JSON
{
"name": "John Wick",
"description": "My name is John Wick",
"image": "image url",
"color": "teal"
}
You can set the following colors:
  • grey => #616266
  • purple => #5b3cb6
  • green => #477b19
  • blue => #3761a8
  • orange => #9b6132
  • pink => #993b9a
  • teal => #3b7e9a
  • red => #9a3b3b

Asset properties

If you are interested to set unique properties to your assets, you can do this via your custom JSON file.
To do this, you will need to set the properties attribute in your JSON file, such as the following example:
JSON
{
"name": "Asset Name",
"description": "Lorem ipsum...",
"image": "https:\/\/s3.amazonaws.com\/your-bucket\/images\/{id}.png",
"properties": {
"simple_property": "example value",
"rich_property": {
"name": "Name",
"value": "123",
"display_value": "123 Example Value",
"class": "emphasis",
"css": {
"color": "#ffffff",
"font-weight": "bold",
"text-decoration": "underline"
}
},
"array_property": {
"name": "Name",
"value": [1,2,3,4],
"class": "emphasis"
}
}
}
You can set as many different properties as you'd like. Once set, these unique properties will display on your asset in the Enjin Wallet app, and on EnjinX.

Localization

Metadata localization should be standardized to increase presentation uniformity across all languages. As such, a simple overlay method is proposed to enable localization. If the metadata JSON file contains a localization attribute, its content MAY be used to provide localized values for fields that need it. The localization attribute should be a sub-object with three attributes: uri, default and locales. If the string {locale} exists in any URI, it MUST be replaced with the chosen locale by all client software.
BaseURI
{
"name": "Advertising Space",
"description": "Each token represents a unique Ad space in the city.",
"localization": {
"uri": "ipfs://QmWS1VAdMD353A6SDk9wNyvkT14kyCiZrNDYAad4w1tKqT/{locale}.json",
"default": "en",
"locales": ["en", "es", "fr"]
}
}
es.json
{
"name": "Espacio Publicitario",
"description": "Cada token representa un espacio publicitario único en la ciudad."
}
fr.json
{
"name": "Espace Publicitaire",
"description": "Chaque jeton représente un espace publicitaire unique dans la ville."
}

Setting Metadata based on the NFT index

When setting individual images and descriptions for NFTs, we must take into consideration the fact that NFTs are unique and the whole purpose of having NFTs is the ability to set different parameters for tokens that share the same token ID with individual indexes.
Note: When doing this, you need your own internal CDN, somewhere to host the metadata URI JSON files.

Example:

Index 0: Token Group
Index +1: Individual Tokens
This is the asset that we are going to use as an example of how to set individual metadata.
This asset has a total supply of 3 NFTs, so we will need to host 4 individual, different JSON files. One for the 0 index:
  • 0x70800000000005c1000000000000000000000000000000000000000000000000
Another 3 for the n+1 indexes:
  • 0x70800000000005c1000000000000000000000000000000000000000000000001
  • 0x70800000000005c1000000000000000000000000000000000000000000000002
  • 0x70800000000005c1000000000000000000000000000000000000000000000003
On your hosted CDN, you will need to host the files there accordingly, your image(s) of the NFTs and the JSON files. We typically name our hosted files like the following:
  • cdn.enjin.io/mint/image/70800000000005c1000000000000000000000000000000000000000000000000.jpg for the hosted image, and
  • cdn.enjin.io/mint/image/70800000000005c1000000000000000000000000000000000000000000000000.json for the hosted JSON file.
  • Note the ending of the hosted files (.jpg for the image, and .json for the metadata file).
You will want to host them in order by the NFT index, so the token ID at the start, then the token Index at the end before the {.json}.

Example:

  1. 1.
    cdn.enjin.io/mint/file/70800000000005c1000000000000000000000000000000000000000000000001.json
  2. 2.
    cdn.enjin.io/mint/file/70800000000005c1000000000000000000000000000000000000000000000002.json

Step 2

Now that we have all of our files hosted based on the full token id (without the 0x) and index, it's time to set the metadata in the web panel. You will need to go to the Advanced Editor option.
https://cdn.enjin.io/mint/meta/{id}.json - This should be the path that we set in the Metadata URI field of the web panel, it means that EnjinX and our Platform/API, will query for the token id related to that specific token, and the index sequence.
Paste your own CDN path in the Metadata URI field and ensure you have titled {id}.json in the file as shown in our example screenshot above. After setting it up, accept the request in the wallet and you should have an NFT with different images based on the token index.
It's also possible to set the metadata using the GraphQL Playground with the SetUri mutation.

Invalidating Asset Metadata

If your asset metadata doesn't load or takes a while to load, we have implemented the Invalidate Metadata mutation to push the metadata through our servers so that your asset metadata can appear instantly.
mutation InvalidateTokenMetadata {
InvalidateAssetMetadata(id: "<tokenId>")
}
Id is the token ID of the asset you want to invalidate.
This mutation will instruct the Platform to invalidate the metadata and thus fetch it again, directly from your server.
Please note the following when running this particular mutation:
  1. 1.
    It can take a few minutes, after invalidating your asset, for the new metadata to load.
  2. 2.
    This mutation can only be run once, per asset, every few minutes.
  3. 3.
    You can only run this mutation on assets that belong to a project, in which you have the minter role (or higher) on.