ERC-5185 · Stagnant · ERC · 2022-06-27
ERC-5185: NFT Updatable Metadata Extension
Lets NFT metadata evolve only through recipes declared up front in the original metadata, with each batch of updates announced by an on-chain event, so anyone can deterministically recompute and verify a token's current metadata.
What problem does it solve?
NFT metadata usually sits at a tokenURI. If that URI points to an immutable file (e.g. IPFS), nothing can ever change. If it points to a server, the issuer can change anything at any time. Many use cases sit in between: a game character whose level rises but whose looks are fixed, or a property title where the owner history may only be appended.
ERC-5185 adds a middle ground: the original metadata declares which transformations are allowed, and updates are applied as a verifiable, ordered log.
How it works
- The original metadata (from
tokenURIin ERC-721 oruriin ERC-1155) gains anupdatableobject with:engine: the transformation language and version. The only one defined is[email protected].*.recipes: named formulas (evalstrings) that transform the previous JSON.- optional
schema: a JSON Schema every updated version must satisfy.
- The contract emits
MetadataUpdates(string URI). The URI points to a JSON file listing updates, each with atokenId, arecipeKeyand optionalargs. One event can batch thousands of updates for many tokens. - To get current metadata, a client starts from the original and applies every update for that token, in event order:
next = jsonata(eval).evaluate(prev, args).- Unknown recipe key, evaluation error, or schema violation: the update is ignored and
previs kept.
- Unknown recipe key, evaluation error, or schema violation: the update is ignored and
Because the process is deterministic, marketplaces can cache intermediate results and only apply new events. Gas cost is just one event per batch.
Sample code
Contract side:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC5185UpdatableMetadata {
event MetadataUpdates(string URI);
}
contract Monsters is IERC5185UpdatableMetadata /*, ERC721 */ {
address public gameMaster;
function publishUpdates(string calldata uri) external {
require(msg.sender == gameMaster, "only GM");
emit MetadataUpdates(uri); // e.g. "ipfs://<cid>/updates-0042.json"
}
}
Original metadata with recipes, and an updates file (field names follow the spec's schema):
{
"name": "Monster 1",
"attributes": [{ "trait_type": "Level", "value": 0 }],
"updatable": {
"engine": "[email protected].*",
"recipes": {
"levelUp": { "eval": "$ ~> | attributes[trait_type='Level'] | {'value': value + 1} |" }
}
}
}
{ "updates": [ { "tokenId": "1", "recipeKey": "levelUp" }, { "tokenId": "1", "recipeKey": "levelUp" } ] }
Client-side replay (TypeScript, using the jsonata package):
import jsonata from "jsonata";
async function current(original: any, updates: { tokenId: string; recipeKey: string; args?: any }[], id: string) {
let meta = original;
for (const u of updates.filter((u) => u.tokenId === id)) {
const recipe = original.updatable?.recipes?.[u.recipeKey];
if (!recipe) continue;
try { meta = await jsonata(recipe.eval).evaluate(meta, u.args); } catch { /* keep prev */ }
}
return meta;
}
Things to know
- Status is Stagnant: the proposal is not progressing, and marketplace support should not be assumed.
- The spec is internally inconsistent: its schema calls the field
recipeKey(withargsas a string), while its example usesactionand passesargsas an object. Pick one and document it. - Recipes run arbitrary JSONata on third-party infrastructure; the spec warns this can be a DoS vector, so evaluators should sandbox and limit processing.
- If a contract later changes
tokenURI, the "original" changes too, and earlier updates may no longer apply cleanly. - For simply signaling "metadata changed, refresh", the widely supported option is ERC-4906.