ERC-5185 Updatable Metadata Extension for NFTs (NFT Updatable Metadata Extension)
Stagnant · NFTs & multi-token · created 2022-06-27
An extension that changes NFT metadata step by step according to predefined formulas (recipes) and records those changes as on-chain events, so that anyone can recompute and verify them.
Why it is needed
Storing NFT metadata entirely on-chain is expensive, and uploading it to a decentralized store like IPFS guarantees permanence but means that changing it requires completely replacing the tokenURI itself. This works for permanently fixed assets like artwork, but not for attributes that need to change incrementally, like a game character's level or health, or information that needs to keep accumulating, like ownership history. When each project builds its own change logic, marketplaces or external tools have no common way to confirm whether a change is legitimate or what the latest metadata is.
What to implement
event MetadataUpdates(string URI);: An event that emits a URI pointing to a batch of metadata changes. This URI must point to a JSON file that follows the 'NFT Metadata Updates JSON Schema', and marketplaces and others can deterministically compute the latest metadata by applying these events in tokenId order.
In depth
Scope of application and optionality
This extension is an OPTIONAL metadata update extension that can be added to ERC-721 and ERC-1155 contracts. It requires ERC-721 and ERC-1155, and defines the JSON returned by either standard's tokenURI or uri function as that token's 'original metadata'.
The MetadataUpdates event
The IERC5185UpdatableMetadata interface defines only a single event, MetadataUpdates(string URI). This URI is in RFC 3986 format and must point to a JSON file that follows the 'NFT Metadata Updates JSON Schema'. Third party platforms such as marketplaces can deterministically compute each token's latest metadata by applying, in order, the updates from all events whose tokenId matches.
The updatable field in the original metadata
The original metadata SHOULD follow the 'ERC-5185 Updatable Metadata JSON Schema', an extension of the ERC-721 Metadata JSON Schema. In addition to name, description, and image, an updatable object is added, requiring engine (the transformation method and version), schema (optional, a JSON Schema the transformed JSON must satisfy), and recipes (a list of recipes identified by key). Each recipe holds its transformation formula as a string in the eval field.
Update list JSON
The document 'NFT Metadata Updates JSON Schema' that the event points to has an updates array. Each item in the array requires a tokenId and a recipeKey, and may optionally include args to pass to the transformation. The recipeKey is the key that selects which transformation formula to apply from the recipes list in the original metadata.
jsonata engine evaluation rules
Currently the spec defines only one engine: 'jsonata@1.8.*'. In this engine, the evalString found via recipeKey is computed as jsonata(evalString).evaluate(previousMetadata, args) to obtain the next metadata. If the recipeKey is not found in the recipes list of the original metadata, an error occurs during evaluation, or a schema is defined but the resulting JSON does not conform to it, the update is treated as invalid and previousMetadata is kept unchanged.
Verifiability and gas efficiency
Using only the event logs left on chain, anyone can independently recompute and verify all changes from the original metadata up to the present. Because the computation is deterministic, it is also possible to cache intermediate transformation results and process only the new updates incrementally. The number of updates carried in a single event can scale to thousands or even millions depending on contract logic, allowing many changes across multiple tokens to be batched into the cost of a single emit.
Stagnant status
This proposal is currently in Stagnant status, meaning it has stalled with no active discussion or progress.
Things to watch out for
- DDoS risk from malicious recipes: If malicious recipes are embedded in the original metadata, they can become a vector for DDoS attacks against marketplaces or tools that compute them. It is recommended that software responsible for computation be properly sandboxed and that limits be placed on engine processing.
- Interaction with tokenURI changes: If a contract using this extension also allows the value returned by tokenURI or uri to be changed directly, careful consideration is needed as to whether existing broadcast updates remain compatible with the new original metadata, and how the two kinds of changes should be combined in meaning.