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
- 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.
- Call
commiton a compliant contract with the CID and a free-formcommitDatastring (for example a pointer to metadata, an action description or an edit record). - The contract emits a
Commitevent and returns the block number. The reference implementation also stores the block numbers per CID so they can be read back withgetCommits.
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
commitDatais true. Anyone can commit anything about any CID, so trust comes from who therecorderis, not from the record existing. - Because
assetCidis an indexedstring, 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 incommitDataor in storage if you need it. - Indexers should handle reorgs and possibly missed events when building a history from logs.