ERC-8493: Onchain URI Scheme

ERC-8048 and ERC-8049 store metadata onchain as key-value pairs, but a JSON document has no compact way to point at those values. A URL that names the contract, the chain, and the token ID repeats what the client already knows and differs for every token.

ERC-8493 defines the onchain URI scheme. The contract and token ID are not written in the URI, they come from the function that returned the document.

{
  "image": "onchain:image/png",
  "thumbnail": {
    "small": "onchain:image/png?key=thumb.small"
  }
}

onchain:image/png is 17 bytes and works unchanged for every token. When the URI comes from tokenURI or uri, the client reads it with metadata(tokenId, key) from ERC-8048, and when it comes from contractURI, with metadata(key) from ERC-8049. A direct member of the top-level document uses its own name as the key, and everywhere else the key parameter names it.

Tokens that are already deployed can use the scheme by adding a metadata_contract property to their JSON, which points the client at a separate metadata contract. Linked JSON documents keep the same contract and token, so the whole thing reads as one data tree.

The scheme adds no contract surface. Existing ERC-8048 and ERC-8049 contracts support it with no change, and a client that does not know the scheme sees a URI it can ignore.

PR: Add ERC: Onchain URI Scheme by nxt3d · Pull Request #2158 · ethereum/ERCs · GitHub

Feedback is welcome, especially from wallets, marketplaces, and indexers.