Setting Metadata on your first Enjin Token

Learn how to set metadata on your first Enjin token.
For the Advanced Metadata guide, please refer to this link here.

Basic Editor

Now that we have already created our token template with the id 70800000000029b7, it is time for us to add a valid metadata file on it, which represents the off-chain data attached to the token, such as the name, image, and description.
This information can be stored using the Enjin asset editor as shown here
Your asset URI will then be customized to point towards Enjin’s servers, where the metadata is stored.
You can also upload .GIF and .MP4 files to your assets.
Requirements when using hosted metadata:
  • 5Mb max for GIFs/regular images.
  • 15Mb max for MP4 videos.

Advanced Editor

If you want full control over your metadata, you can choose the URI using the Advanced Editor.
Your asset URI will then be customized to point toward the address you have specified and you will be able to customize the JSON file at your leisure.
Please note the following requirements when it comes to hosting your own metadata:
  1. 1.
    The link (to both metadata and image) must be publicly accessible to robots.
  2. 2.
    The URI must be set appropriately to the requested file.
  3. 3.
    The image must be that of a valid image file (the image must display online).
  4. 4.
    The JSON must conform with the JSON RFC standards. If it does not conform in any way, then your metadata won't be loaded by Enjin.
  5. 5.
    If in doubt, we recommend checking your metadata here, to make sure it's valid.
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"
}

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.

Using Enjin's API

If you want to set your metadata programmatically, you can do so using the following query:
mutation {
SetUri(
assetId: "70800000000029b7"
uri:"your uri url here"
wallet: "your wallet address"
) {
transactionId
id
state
value
asset {
name
id
}
user {
name
}
}
}
The ERC-1155 token standard includes optional formatting to allow for ID substitution by clients. If the string {id} exists in any JSON value, it MUST be replaced with the actual token ID, by all client software that follows this standard.
  • The string format of the substituted hexadecimal ID MUST be lowercase alphanumeric: [0-9a-f] with no 0x prefix.
  • The string format of the substituted hexadecimal ID MUST be leading zero-padded to 64 hex characters length if necessary.
In this situation, the following address: https://token-cdn-domain/{id}.json
Would be replaced with: https://token-cdn-domain/780000000000001e000000000000000000000000000000000000000000000000.json
If the request sent by you has all parameters correct, the response from the platform should be -
{
"data": {
"SetUri": {
"transactionId": null,
"id": 98422,
"state": "PENDING",
"value": "0",
"asset": {
"name": "NFT Test",
"id": "70800000000029b7"
},
"user": null
}
}
}
The request should be approved in your wallet under the requests tab, after that is done, we are ready to mint your first token!
🚀