ERC-7729 ERC-20 Token with Metadata (Token with Metadata)
Draft · Tokens · created 2023-06-24
Adds a metadata() function to an ERC-20 token, standardizing a way to look up the address (URI) of a JSON file containing the token's name, description, and image.
Why it is needed
ERC-20, the widely used fungible token standard on Ethereum, has no standardized way to attach metadata, such as an image or description, that represents a token. The original text explains that memecoins demonstrated the value of attaching visual metadata to tokens. When every token provides metadata in its own way, wallets and apps struggle to read a token's visual information consistently. This proposal starts from the motivation that standardizing how metadata is attached to ERC-20 tokens would let developers build more engaging, interactive tokens and thereby grow community participation. It therefore defines a single function that returns a metadata URI, along with the format (schema) of the JSON file that URI points to.
What to implement
function metadata() external view returns (string memory);: Returns the metadata URI linked to the token. This URI may point to a JSON file that follows the metadata JSON schema defined by the standard.
In depth
Required scope of implementation
Every contract that conforms to the standard MUST implement both the IERC7729 interface and the ERC-20 interface. The only function added is metadata(), a view function that returns the metadata URI linked to the token as a string. This URI MAY point to a JSON file that follows the metadata JSON schema defined by the standard. Note that in the original specification's code block the interface name is written as IERC20Metadata, while the body's requirements and reference implementation use the name IERC7729.
Metadata JSON schema
The JSON that the URI points to is of type object with three properties. name is a string identifying the asset the token represents, description is a string describing that asset, and image is a URI string pointing to an image/* MIME-type resource representing the asset. The original text calls this schema the "ERC-7729 Metadata JSON Schema."
Design Rationale and Backward Compatibility
The function name metadata was chosen based on existing standards and implementation precedents across applications. Because this standard extends existing ERC-20 functionality with a new interface, it is backward compatible with ERC-20. For wallets or contracts that work with existing ERC-20 tokens, only one extra function is added and existing behavior is unchanged.
Reference implementation
The original text's reference implementation is a simple structure that inherits from OpenZeppelin's ERC20 contract, stores an ipfs:// style URI in a string state variable called _metadata, and returns it as is from the metadata() function. Only the URI is stored on-chain, not the metadata body itself.
Proposal status
This document is currently in Draft status. Since its contents may still change, it is best to check the latest original text before implementing.
Things to watch out for
- Malicious URI risk: A metadata URI could be manipulated to point to malicious content or a phishing site. Off-chain indexers must perform a verification process to confirm the security and integrity of metadata URIs on behalf of users.