ERC-3440 ERC-721 Edition Signature Standard (ERC-721 Editions Standard)
Stagnant · NFTs & multi-token · created 2021-04-20
An ERC-721 extension that lets an artist leave their own EIP-712 signature on an NFT, specify the quantities of the original and limited editions on-chain, and prove the authenticity of the work.
Why it is needed
ERC-721 was originally created to handle certificates or game tokens, and the link between an NFT and the real-world work depends only on tokenURI metadata stored on an external server. While the blockchain immutably records token issuance, the key used to create that provenance is often not managed as tightly as an artist would manage a handwritten signature. Furthermore, since the ERC-721 contract may not be deployed by the artist directly, verifying whether a given NFT actually passed through the artist's hands required relying on a third-party application that trusts metadata outside the blockchain. There was no standard for distinguishing an original work from a reproduction, or for trustlessly verifying the quantity and signature of a limited edition.
What to implement
event Signed(address indexed from, uint256 indexed tokenId);: An event emitted when the artist signs a token.function _designateArtist(address _artist) internal virtual: Sets the artist address exactly once, designating that wallet as the original creator.function _designateOriginal(uint256 _tokenId) internal virtual: Callable only by the artist; designates an existing token ID as the original (originalId) exactly once.function _setLimitedEditions(uint256 _maxEditionSupply) internal virtual: Callable only by the artist; sets the maximum number of editions to be minted (editionSupply) exactly once.function _createEditions(string memory _tokenURI) internal virtual: Mints tokens sequentially from 0 up to editionSupply and assigns them the same tokenURI.function _hash(Signature memory _message) internal view returns (bytes32): Computes the EIP-712 signature digest using DOMAIN_SEPARATOR and SIGNATURE_TYPEHASH.function _signEdition(uint256 _tokenId, Signature memory _message, bytes memory _signature) internal virtual: Callable only by the artist; stores a signature for an as-yet-unsigned token whose signer matches the artist, and emits a Signed event.function getSignature(uint256 _tokenId) external view virtual returns (bytes memory): Retrieves the signature bytes stored for a given token.function isSigned(Signature memory _message, bytes memory _signature, uint _tokenId) external view virtual returns (bool): Checks whether a given message and signature belong to the artist and match the signature stored for that token.function _equals(bytes memory _self, bytes memory _other) internal pure returns (bool equal): An internal utility that efficiently compares two bytes values for equality via hash comparison.function sign(uint256 _tokenId, Signature memory _message, bytes memory _signature) public: A public function in the reference implementation that wraps _signEdition, allowing the artist to externally register a signature for a given edition.
In depth
Designating the Original and Limited Editions
The implementation must designate which token ID is the original (originalId); the default is 0, but it can be set to a different ID. The original can be designated only once via the _designateOriginal function, and the caller must be the artist address. The maximum number of editions that can be minted (editionSupply) must also be specified, and token IDs beyond this number cannot be minted.
Edition Minting Process
After _setLimitedEditions sets the maximum supply (_maxEditionSupply) exactly once, _createEditions sequentially _mints tokens from 0 up to editionSupply and sets the same _tokenURI for each token. Both functions require the caller to be the artist, and the reference implementation handles this process all at once in the constructor.
The EIP-712 Signature Structure
The signed message must follow the EIP-712 standard, and the Signature struct consists of verificationAddress (fixed to the contract address), artist, wallet, and contents fields. The recommended signing target is the hash of the token ID integer, and the _hash function computes the EIP-712 digest using DOMAIN_SEPARATOR and SIGNATURE_TYPEHASH.
Signature Registration and Verification
_signEdition can only be called by the artist; for a token ID that is not yet signed, it uses ECDSA.recover to confirm that the signer matches the artist, then stores the signature bytes and emits a Signed event. Externally, getSignature can retrieve a stored signature, and isSigned can confirm that a given message and signature belong to the artist and match the signature stored for that token.
Backward compatibility
This extension combines existing ERC-721 extensions (such as ERC721URIStorage) and is backward compatible with the ERC-721 standard.
Proposal status
This ERC is currently in Stagnant status, meaning it is a proposal that is no longer being actively discussed or progressed. Its specification may change or may never be adopted.
Things to watch out for
- One-Time Setup: Designating the original and setting the maximum supply are each allowed only once, to prevent the artist from changing these values after selling the original work and undermining uniqueness and verifiability. The reference implementation handles these functions in the constructor for this reason.
- Signing Only Once: Since an edition can be signed only once, care must be taken to confirm the signature is correct before revealing the token to the public.