Item metadata is linked to the item on-chain via a metadata URL. The metadata itself is stored off-chain. This means item metadata can be updated quickly and often, since it doesn’t require an on-chain transaction to do so.
// Construct the updates you'd like to make
// Note: Metadata must be fully replaced with each update
const itemUpdates = {
"metadata": {
"name": "itemName",
"description": "itemDescription",
"image": "http://url.com/image",
"attributes": [
{
"type": "attribute1",
"value": 20,
"displayType": "number",
"maxValue": 100
},
{
"type": "attribute2",
"value": "value",
"displayType": "string"
}
]
}
}
// Update the item
const response = await fetch('/v1/item-types/{itemTypeId}', {
method: 'PUT',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(itemUpdates),
});
const data = await response.json();