EIPs Explained

ERC-7603 · Draft · ERC · 2024-01-25

ERC-7603: ERC-1155 Multi-Asset extension

An ERC-1155 extension that lets each token carry several prioritised assets (image, PDF, 3D model…) so each app can pick the representation that fits its context.

What problem does it solve?

An ERC-1155 token has one metadata URI per token ID. But the same item may need different outputs in different places: an e-book token should open as a PDF in a reader and an MP3 in an audiobook app; a game cosmetic needs one file for game A, another for game B and a thumbnail for marketplaces. Metadata hosted on a single server or IPFS gateway can also simply disappear.

ERC-7603 brings the "multi-asset" idea, already standardised for ERC-721 in ERC-5773, to ERC-1155. A token can point at several assets, effectively "namespaced token URIs", and the consuming app chooses the one appropriate to its context. The same metadata can also be stored on several networks as separate assets for redundancy.

How it works

  • Assets are created once with a uint64 ID (AssetSet event) and then attached to one or more tokens (AssetAddedToToken, which can also name an asset being replaced).
  • getAssets(tokenId) returns the asset IDs on a token; getAssetMetadata(tokenId, assetId) returns that asset's metadata string (typically a URI).
  • Each token has a priority array, one value per asset, set with setPriority (AssetPrioritySet event). Lower values mean higher priority; 0 means uninitialised. getAssetPriorities(tokenId) reads it.
  • Assets do not need to share MIME types or depend on each other. How assets are created and who may attach them is not specified by the interface.

The contract stays a normal ERC-1155, so existing tooling keeps working.

Sample code

Picking the highest-priority asset in TypeScript (ethers v6):

import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const token = new Contract(collection, [
  "function getAssets(uint256) view returns (uint64[])",
  "function getAssetPriorities(uint256) view returns (uint64[])",
  "function getAssetMetadata(uint256, uint64) view returns (string)",
], provider);

const tokenId = 1n;
const [ids, prios]: [bigint[], bigint[]] = await Promise.all([
  token.getAssets(tokenId),
  token.getAssetPriorities(tokenId),
]);

// lowest non-zero priority wins; 0 means "not set"
let best = -1;
ids.forEach((_, i) => {
  if (prios[i] !== 0n && (best < 0 || prios[i] < prios[best])) best = i;
});
const chosen = best >= 0 ? ids[best] : ids[0];
console.log(await token.getAssetMetadata(tokenId, chosen));

Things to know

  • Status is Draft. The Rationale and Security Considerations sections are still placeholders.
  • No ERC-165 interface ID is stated in the spec yet.
  • The comments in the interface describe priorities as uint16 while the function signatures use uint64; follow the signatures, and expect this to be cleaned up.
  • Unlike ERC-5773, this draft has no pending/accept step for new assets, so whoever controls asset assignment can change what users see. Define and document access control carefully.

#erc1155 #multi-asset #metadata #nft #gaming

Details

Authors
Haru (@haruu8)
Status
Draft
Type
Standards Track / ERC
Created
2024-01-25
Requires

Machine-readable: Markdown · JSON