ERC-5773 · Final · ERC · 2022-10-10
ERC-5773: Context-Dependent Multi-Asset Tokens
Lets a single NFT carry several prioritised assets (image, 3D model, PDF, firmware…) so each app can pick the right one, with new assets added only by issuer proposal plus owner acceptance.
What problem does it solve?
An ERC-721 token has one tokenURI. That is awkward when the same item should look different depending on where it is used: an e-book NFT should open as a PDF in a reader, an MP3 in an audiobook app and a cover image on a marketplace; a game item may need a different model file for each game.
The usual workaround, changing the tokenURI, also has a trust problem: the issuer can silently swap what the owner holds, and the history is lost. ERC-5773 introduces multi-asset NFTs: one token, many outputs, ordered by the owner, with an explicit propose-and-accept flow for changes.
How it works
- Assets are stored once in the contract under a
uint64asset ID, each pointing to a metadata URI. A token holds arrays of asset IDs by reference, so the same asset can be attached to many tokens cheaply. - Pending vs active. The issuer (or another authorised party) adds an asset to a token's pending list (
AssetAddedToTokens). The token owner then callsacceptAssetto move it to the active list, orrejectAsset/rejectAllAssetsto drop it. The pending list should be capped (the spec suggests 128) to prevent spam. - Replacement. A proposed asset can name an existing asset it replaces (
getAssetReplacements). On acceptance it takes that asset's place, which supports "evolution" or firmware-update style flows while keeping the lineage visible on-chain. - Priorities.
setPrioritylets the owner order active assets; lower values mean higher priority. Consumers readgetActiveAssetsandgetActiveAssetPriorities, thengetAssetMetadata(tokenId, assetId)for the URI. - Asset approvals (
approveForAssets,setApprovalForAllForAssets) are separate from transfer approvals and are cleared when the token is transferred. - Accept/reject calls pass both an array
indexand the expectedassetId, giving constant gas cost while guarding against the array shifting underneath the call.
The interface's ERC-165 ID is 0x06b4329a.
Sample code
Picking the highest-priority asset for display (ethers v6):
import { Contract, JsonRpcProvider } from "ethers";
const abi = [
"function getActiveAssets(uint256) view returns (uint64[])",
"function getActiveAssetPriorities(uint256) view returns (uint64[])",
"function getAssetMetadata(uint256,uint64) view returns (string)",
];
const nft = new Contract(nftAddress, abi, new JsonRpcProvider(process.env.RPC_URL));
const ids: bigint[] = await nft.getActiveAssets(tokenId);
const prios: bigint[] = await nft.getActiveAssetPriorities(tokenId);
if (ids.length > 0) {
let best = 0;
prios.forEach((p, i) => { if (p < prios[best]) best = i; }); // lowest = top priority
console.log(await nft.getAssetMetadata(tokenId, ids[best]));
}
Owner accepting a pending asset (Solidity call):
uint64[] memory pending = IERC5773(nft).getPendingAssets(tokenId);
IERC5773(nft).acceptAsset(tokenId, 0, pending[0]); // index + expected id
Things to know
- Status is Final. It is fully compatible with ERC-721, so ordinary wallets still see a normal NFT.
- The suggested asset-metadata JSON (
mediaUri,thumbnailUri,attributes, …) is optional; implementers may structure it differently. - Active assets cannot simply be deleted by the issuer; they can only be replaced through an accepted proposal, which is the main trust guarantee.
- The same author group built related standards on top: nestable NFTs in ERC-6059 and equippable parts in ERC-6220.
- As with any NFT contract, unaudited implementations may hide logic in add/accept/burn functions.