Treasureland
Search…
MetaData Standard
Providing asset metadata allows applications to pull in rich data for digital assets and easily display them in-app. Digital assets on a given smart contract are typically represented sol

Implementing token URI

For Treasureland 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.
1
**
2
* @dev Returns an URI for a given token ID
3
*/
4
function tokenURI(uint256 _tokenId) public view returns (string) {
5
return Strings.strConcat(
6
baseTokenURI(),
7
Strings.uint2str(_tokenId)
8
);
9
}
Copied!
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

1
{
2
"description": "Meebit #7241",
3
"image": "http://meebits.larvalabs.com/meebitimages/characterimage?index=7241&type=full&imageType=jpg",
4
"name": "Meebit",
5
"attributes": [ ... ],
6
}
Copied!
Here's how each of these properties work:
image
This is the URL to the image of the item. Can be just about any type of image (including SVGs, which will be cached into PNGs by OpenSea), and can be IPFS URLs or paths. We recommend using a 350 x 350 image.
image_data
Raw SVG image data, if you want to generate images on the fly (not recommended). Only use this if you're not including the image parameter.
external_url
This is the URL that will appear below the asset's image on OpenSea and will allow users to leave OpenSea and view the item on your site.
description
A human readable description of the item. Markdown is supported.
name
Name of the item.
attributes
These are the attributes for the item, which will show up on the OpenSea page for the item. (see below)
background_color
Background color of the item on OpenSea. Must be a six-character hexadecimal without a pre-pended #.
animation_url
A URL to a multi-media attachment for the item. The file extensions GLTF, GLB, WEBM, MP4, M4V, OGV, and OGG are supported, along with the audio-only extensions MP3, WAV, and OGA.
Animation_url also supports HTML pages, allowing you to build rich experiences and interactive NFTs using JavaScript canvas, WebGL, and more. Scripts and relative paths within the HTML page are now supported. However, access to browser extensions is not supported.
youtube_url
A URL to a YouTube video.

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:
1
...
2
{
3
"attributes": [
4
{
5
"trait_type": "Base",
6
"value": "Starfish"
7
},
8
{
9
"trait_type": "Eyes",
10
"value": "Big"
11
},
12
{
13
"trait_type": "Mouth",
14
"value": "Surprised"
15
},
16
{
17
"trait_type": "Level",
18
"value": 5
19
},
20
{
21
"trait_type": "Stamina",
22
"value": 1.4
23
},
24
{
25
"trait_type": "Personality",
26
"value": "Sad"
27
},
28
{
29
"display_type": "boost_number",
30
"trait_type": "Aqua Power",
31
"value": 40
32
},
33
{
34
"display_type": "boost_percentage",
35
"trait_type": "Stamina Increase",
36
"value": 10
37
},
38
{
39
"display_type": "number",
40
"trait_type": "Generation",
41
"value": 2
42
}
43
]
44
}
Copied!
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, Treasureland 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 Treasureland 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

Treasureland 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 Treasureland 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.