EIPs Explained

ERC-7280 · Draft · ERC · 2023-07-04

ERC-7280: NFT Metadata Extension like JSON-LD

A draft extension to NFT metadata that adds a `linked_data` array pointing to schemas and data documents, so NFTs can carry structured, JSON-LD style semantic information.

What problem does it solve?

NFT metadata (the JSON returned by tokenURI in ERC-721 or uri in ERC-1155) is mostly a flat set of fields: name, description, image, and free-form attributes. There is no standard way to say "this token is a video, and here is its data described by this schema", so applications cannot reliably interpret richer information.

ERC-7280 borrows the idea of JSON-LD (linked data): the metadata points to a schema and to a data document that follows it. Any application that understands a given schema can then use the data, and a website showing the NFT could embed the linked JSON-LD in its HTML head so search engines can produce rich results.

How it works

The proposal adds one optional key, linked_data, to the existing metadata JSON. It is an array, so one NFT can describe itself with several schemas at once. Each element has two required objects:

Object Field Required Meaning
schema uri yes Where the schema lives
schema name yes Name of the schema (e.g. VideoObject)
schema description no Human description of the schema
data uri yes Where the data document lives
data lang no IETF language tag such as en-US
data name, description no Optional labels for the data

A consumer scans linked_data, picks entries whose schema it recognises, fetches data.uri, and uses the result. Everything else in the metadata stays the same, so existing wallets and marketplaces simply ignore the new key.

Sample code

Metadata with one linked-data entry:

{
  "name": "Concert Clip #12",
  "description": "Short video from the 2024 tour.",
  "image": "https://example.org/images/12.png",
  "linked_data": [
    {
      "schema": {
        "name": "VideoObject",
        "uri": "https://example.org/schemas/VideoObject.json"
      },
      "data": {
        "uri": "https://example.org/data/clip12.json",
        "lang": "en-US"
      }
    }
  ]
}

Reading it in TypeScript (ethers v6) and picking a schema the app understands:

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 meta = await (await fetch(await nft.tokenURI(12n))).json();
const video = (meta.linked_data ?? []).find((e: any) => e.schema?.name === "VideoObject");
if (video) {
  const data = await (await fetch(video.data.uri)).json();
  console.log("linked video data:", data);
}

Things to know

  • Status: Draft. Field names and structure may still change, and there is no guarantee that wallets or marketplaces read linked_data.
  • Despite the name, the format is "like" JSON-LD: the schema and data are referenced by URI rather than being an inline @context document.
  • The spec lists ERC-721, ERC-1155 and ERC-3525 as base standards; any token whose metadata is JSON can use it.
  • Linked documents are fetched from external URIs. Treat them as untrusted input: validate them against the schema and be careful when embedding them into web pages.
  • If the linked URIs are on mutable web servers, the NFT's meaning can change after minting. Content-addressed storage avoids that.

#nft #metadata #json-ld #semantic

Details

Authors
Yohei Nishikubo (@yoheinishikubo)
Status
Draft
Type
Standards Track / ERC
Created
2023-07-04
Requires

Machine-readable: Markdown · JSON