EIPs Explained

ERC-5625 · Final · ERC · 2022-09-08

ERC-5625: NFT Metadata JSON Schema dStorage Extension

Adds an optional dStorage object to ERC-721 and ERC-1155 metadata JSON that records which decentralized storage network holds the NFT's asset and how to verify it.

What problem does it solve?

An NFT contract records ownership on-chain, but the image, video or file the token represents almost always lives somewhere else. The metadata schemas from ERC-721 and ERC-1155 (and marketplace conventions built on top of them) describe name, description, image and so on, but say nothing about where or how durably the asset is stored.

ERC-5625 fills that gap with a single, optional metadata field so collectors and tools can see whether an asset sits on a decentralized storage network such as Arweave, Filecoin, Swarm or Crust, and find a pointer that proves it was stored.

How it works

The metadata JSON returned by tokenURI (ERC-721) or uri (ERC-1155) may include a dStorage object. If present, all six of its string fields are required:

Field Meaning
platform Name of the storage network (e.g. Arweave, Filecoin)
description Short description of that platform
persistence_mechanism How data is kept alive or incentivized, e.g. "blockchain-based", "contract-based"
challenge_mechanism How storage is proven, e.g. Arweave's proof-of-access
consensus The platform's consensus, e.g. PoW, PoS
dstorage_note Evidence of storage for this asset, e.g. a Filecoin deal id or a Crust storage-order transaction hash

Nothing changes in the smart contract. The authors deliberately chose a JSON schema extension over a new interface so that already-deployed collections can adopt it just by updating their metadata files.

Sample code

ERC-721 metadata with a dStorage block (values are illustrative placeholders):

{
  "name": "Sunset #42",
  "description": "A generative sunset.",
  "image": "ar://<arweave-tx-id>",
  "dStorage": {
    "platform": "Arweave",
    "description": "Permanent, pay-once decentralized storage",
    "persistence_mechanism": "blockchain-based",
    "challenge_mechanism": "proof-of-access",
    "consensus": "<platform consensus>",
    "dstorage_note": "<arweave-tx-id>"
  }
}

Reading it from a client (ethers v6):

import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const nft = new Contract(nftAddress, ["function tokenURI(uint256) view returns (string)"], provider);
const uri: string = await nft.tokenURI(42n);
const meta = await (await fetch(uri.replace("ipfs://", "https://ipfs.io/ipfs/"))).json();
if (meta.dStorage) console.log(`stored on ${meta.dStorage.platform}: ${meta.dStorage.dstorage_note}`);

Things to know

  • Status is Final, but the field is optional; most NFT metadata does not include it, so treat its absence as "unknown", not "centralized".
  • The field is purely informational. It does not prove anything on its own: a client that cares must check the dstorage_note against the named storage network itself.
  • It does not affect contract behaviour or transfer validity, and is fully backwards compatible with ERC-721 and ERC-1155 metadata.

#nft #metadata #storage #json

Details

Authors
Gavin Fu (@gavfu), Leo Wang (@wanglie1986), Bova Chen (@appoipp), Guang Han (@pangwa), Brian Wu (@wuhaixian1984)
Status
Final
Type
Standards Track / ERC
Created
2022-09-08
Requires

Machine-readable: Markdown · JSON