ERC-7572: Contract-level metadata via `contractURI()`

Specifying and updating contract-level metadata


Metadata
Status: DraftStandards Track: ERCCreated: 2023-12-06
Authors
Devin Finzer (@dfinzer), Alex Atallah (@alexanderatallah), Ryan Ghods (@ryanio)

Abstract


This specification standardizes contractURI() to return contract-level metadata. This is useful for dapps and offchain indexers to show rich information about a contract, such as its name, description and image, without specifying it manually or individually for each dapp.

Motivation


Dapps have included supported for contractURI() for years without an ERC to reference. This standard also introduces the event ContractURIUpdated() to signal when to update the metadata.

Specification


The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.

The contract MUST implement the below interface:


The string returned from contractURI() MAY be an offchain resource or onchain JSON data string (data:application/json;utf8,{}).

The ContractURIUpdated() event SHOULD be emitted on updates to the contract metadata for offchain indexers to query the contract.

If the underlying contract provides any methods that conflict with the contractURI schema such as name() or symbol(), the metadata returned by contractURI() is RECOMMENDED to take precedence. This enables contract creators to update their contract details with an event that notifies of the update.

Schema for contractURI

The schema for the JSON returned from contractURI() MUST conform to:


Example:


Future ERCs MAY inherit this one to add more properties to the schema for standardization.

Rationale


The method name contractURI() was chosen based on its existing implementation in dapps. The event ContractURIUpdated() is specified to help offchain indexers to know when to refetch the metadata.

Backwards Compatibility


As a new ERC, no backwards compatibility issues are present.

Reference Implementation



Security Considerations


Addresses specified as collaborators should be expected to receive admin-level functionality for updating contract information on dapps that implement this standard.

Copyright


Copyright and related rights waived via CC0.