ERC-8493 On-chain metadata URI scheme (Onchain URI Scheme)

Draft · Names & metadata · created 2026-11-09

An onchain URI scheme that points to a metadata value stored under ERC-8048 and ERC-8049 from within a JSON document using a single short key, instead of repeating the contract address and token ID over and over.

Why it is needed

ERC-8048 and ERC-8049 store metadata on-chain as key-value pairs, but until now there was no concise way for a JSON document to point to one of those values. Typically a URL had to encode the contract address, chain, and token ID, which just repeats information the reader already knows, and because the URL differs per token, the document could not be reused. For example, even a URL pointing to a single image would have to be rewritten for every token ID. The onchain URI scheme eliminates this duplication and defines a reference format, such as onchain:image/png, a short 17-byte string that can be used identically across all tokens.

In depth

URI syntax

An onchain URI consists of "onchain:" followed optionally by a media type and a "?key=" parameter (onchain-uri = "onchain:" [mediatype] ["?key=" enckey]). Since both the media type and the key parameter are optional, onchain:, onchain:image/png, onchain:?key=seat, and onchain:image/png?key=hero are all valid RFC 3986 URIs. The type/subtype/parameter follow the same format as a Content-Type value in RFC 2045 and must not contain whitespace.

Media type handling

Authors SHOULD include a media type except when the field itself defines the type or the value is plain UTF-8 text. When a media type is present, clients must treat it like a data: URI payload of the same type. For a text type with no charset, UTF-8 is assumed. When no media type is present, the standard or field in which the URI appears determines the type; if nothing determines it, clients must treat it as text/plain;charset=utf-8 and must not render it as active content such as HTML or SVG.

Key determination rules

If a key parameter is present, the key is that value percent-decoded once. Characters such as [, ], %, &, =, # must be percent-encoded, but since some authors leave parentheses unencoded, clients are encouraged to accept that form as well. Only when there is no key parameter and the URI is the value of a direct member of the top-level document's root object does that member's name become the key. In every other location, nested objects, arrays, documents linked from other documents, URIs returned directly by functions, a key parameter is required; if absent, clients must treat that URI as having no value. Keys are flat strings with no path semantics, so a dot in a key like thumb.small is just a literal character. Keys are also case-sensitive.

Determining the target contract and lookup function

By default, the contract from which to read the value is the contract that owns the function that returned the URI. However, if the top-level document's root object has a metadata_contract property (the Onchain Metadata Contract Reference extension of ERC-8048 / ERC-8049), the value is read instead from that contract on the same chain. A metadata_contract in any other location has no effect. If the function that returned the URI took a token ID, call ERC-8048's metadata(tokenId, key); if it took no token ID, call ERC-8049's metadata(key). A zero-length byte return or a reverted call both mean there is no value.

Linked documents and nesting

When an onchain URI, or any other URI, links to another JSON document, that document retains the linking document's context (per-token or per-contract) and resolves its own onchain URIs against the same contract and, if per-token, the same token ID. Clients may impose their own limit on nesting depth, but SHOULD resolve at least 5 levels deep.

Reserved key names

metadata_uri and metadata_contract are reserved names. metadata_uri is the key holding a token's JSON document, and metadata_contract is the JSON property specifying the metadata contract. tokenURI or uri may itself directly point to the JSON document via a URI such as onchain:application/json?key=metadata_uri; since there is no member name in that case, the key parameter is required. Authors SHOULD use metadata_uri so implementations can converge on a single name, and SHOULD NOT use either reserved name as a custom key.

Backward compatibility and proposal status

Since this scheme adds no new interface on the contract side, existing ERC-8048 / ERC-8049 contracts are supported unchanged. Clients that cannot interpret the scheme can simply ignore URIs they cannot resolve, and documents using this scheme remain valid JSON for every client. This proposal is currently in Draft status, so details may still change or be abandoned.

Things to watch out for

Original ERC · ← ERCs