EIPs Explained

ERC-7053 · Final · ERC · 2023-05-22

ERC-7053: Interoperable Digital Media Indexing

A simple on-chain index for digital media: anyone calls commit() with a file's content identifier (CID) and some data, and the emitted Commit events form a searchable, cross-contract history of that file.

What problem does it solve?

Photos, videos and other digital media get copied, edited, minted as NFTs and referenced by many systems. Each system tends to track a file in its own way, so there is no common key for asking "what has been recorded about this exact file, by whom, on which chain?". Provenance and metadata end up fragmented.

ERC-7053 proposes a common key, the file's Content Identifier (CID), and a standard way to log records against it. Because a CID is a cryptographic hash of the content, anyone holding the file can recompute it and look up everything committed about it across contracts and EVM chains.

How it works

  1. Compute a CID for the media file. The spec requires a content address from a cryptographic hash and says it should be the same identifier used on decentralised storage, so the CID also locates the file and its metadata.
  2. Call commit on a compliant contract with the CID and a free-form commitData string (for example a pointer to metadata, an action description or an edit record).
  3. The contract emits a Commit event and returns the block number. The reference implementation also stores the block numbers per CID so they can be read back with getCommits.
event Commit(address indexed recorder, string indexed assetCid, string commitData);

function commit(string memory assetCid, string memory commitData)
    public returns (uint256 blockNumber);

The history of a file is the ordered list of Commit events for its CID, potentially across many contracts and chains. NFTs minted before a contract existed can be indexed too, by computing the CID of the file their tokenURI points to.

Sample code

Committing and then querying a file's history (ethers v6):

import { Contract, id } from "ethers";

const abi = [
  "event Commit(address indexed recorder, string indexed assetCid, string commitData)",
  "function commit(string assetCid, string commitData) returns (uint256)",
];
const registry = new Contract(registryAddress, abi, signer);

const cid = "bafy...";                       // CID of the media file
await (await registry.commit(cid, JSON.stringify({ action: "captured" }))).wait();

// Indexed strings are stored as keccak256 hashes in the log topic,
// so filter by the hash of the CID.
const logs = await registry.queryFilter(registry.filters.Commit(null, id(cid)));
for (const l of logs) console.log(l.blockNumber, l.args.recorder, l.args.commitData);

Things to know

  • Status: Final.
  • The contract does not verify anything: it does not check that the CID is valid or that commitData is true. Anyone can commit anything about any CID, so trust comes from who the recorder is, not from the record existing.
  • Because assetCid is an indexed string, the log topic holds its hash, not the text. You can filter by a known CID but cannot read the CID back from the topic alone; keep it in commitData or in storage if you need it.
  • Indexers should handle reorgs and possibly missed events when building a history from logs.

#media #provenance #cid #indexing #events

Details

Authors
Bofu Chen (@bafu), Tammy Yang (@tammyyang)
Status
Final
Type
Standards Track / ERC
Created
2023-05-22
Required by

Machine-readable: Markdown · JSON