ERC-7644 ERC-721 Name Registration Extension (ERC-721 Name Registry Extension)
Draft · Names & metadata · created 2024-03-01
An extension standard that assigns each ERC-721 token a unique name with an expiry date, and lets callers look up a token by name or look up a token's name.
Why it is needed
ERC-721 tokens are distinguished only by numeric token IDs. Numeric IDs are hard for humans to recognize at a glance and make it difficult to intuitively identify who holds which token. Even if you want to give tokens nicknames like usernames, without a common standard each contract does it differently, so wallets and apps cannot read names consistently. Also, if claiming a name once means monopolizing it forever, unused names get locked up and good names can be hoarded. This standard aims to solve these problems by defining a common interface that prevents name collisions within the same NFT contract and gives names a validity period so that expired names become available again.
What to implement
event NameChanged(uint256 indexed tokenId, bytes32 oldName, bytes32 newName, uint256 expiryDate);: An event emitted when a token's name changes. It reports the token ID, the old name, the new name, and the expiry date of the new registration.function nameOf(uint256 tokenId) external view returns (bytes32);: Returns the token's name. Returns an empty bytes32 if there is no name or it has expired.function tokenIdOf(bytes32 _name) external view returns (uint256);: Returns the token ID linked to a name. Returns 0 if no such token exists or the name has expired.function setName(uint256 tokenId, bytes32 _name, uint256 duration) external;: The token owner sets or changes the token's name. duration is the validity period in seconds starting from the time of the call, and the name must not overlap with another unexpired registration.function nameInfo(bytes32 _name) external view returns (uint256 tokenId, uint256 expiryDate);: If the name has not expired, returns the token ID for that name together with its expiry date.
In depth
Interface composition
Implementers MUST provide all functions in the specification. nameOf(tokenId) returns the unexpired name, or an empty bytes32 if none exists or it has expired. tokenIdOf(_name) returns the token ID linked to the name, or 0 if none exists or it has expired. setName(tokenId, _name, duration) lets the token owner set or renew a name, where duration is the validity period in seconds counted from the time of the call. nameInfo(_name) returns the token ID together with the expiry date (expiryDate). When a name changes, a NameChanged(tokenId, oldName, newName, expiryDate) event is emitted. All name types are bytes32.
Why names have an expiry date
Giving name registrations an expiry period keeps the ecosystem healthy by freeing up unused or stale names again. It encourages turnover of names, preventing long-term hoarding, and gives users an incentive to renew names they value and release ones they no longer need. The source text explains that this creates a fair environment where name resources are used efficiently and refreshed to match changing demand.
Name uniqueness
Within the same NFT contract, a name must be unique until it expires. Unique names prevent confusion, support clear and intuitive identification, improve searchability, and build trust in trading and social interactions. Uniqueness is guaranteed within the scope of this contract, and the specification currently requires uniqueness within the NFT contract.
The role of the registration system
The name registration system is designed to prevent abuse and ensure fair access to name resources. The reservation feature gives everyone a fair chance to claim a desired name, preventing hoarding and speculation, while the renewal feature encourages active participation and investment in the ecosystem. Who holds the authority to set a name depends on the specific use case applying this extension.
Safeguards in the reference implementation
The reference implementation checks in setName that ownerOf(tokenId) matches the caller, so only the token owner can change the name. It caps the validity period at MAX_DURATION = 10 * 365 days and sets a minimum re-registration interval of MIN_SET_NAME_INTERVAL = 1 days, to prevent spam from consecutive registrations and indefinite monopolization. Names are managed with two mappings, _tokenNames (token ID to name) and _nameRegistrations (name to token ID and expiry date), and a name already in use can only be reset by the token that currently holds it. This standard is fully compatible with ERC-721.
A Proposal in Draft Stage
The status of this document is Draft. Since it is still an under-review draft and the specification may change, it is advisable to check for the latest status before implementing or depending on it.
Things to watch out for
- Preventing abuse and hoarding: A minimum interval between name settings and a cap on the validity period deter spam, malicious attacks, and consecutive registrations. This prevents names from being monopolized indefinitely, creating a sustainable and fair environment.
- Name length and character restrictions: Names should be kept between 3 and 32 characters. Excessively long names incur high gas costs and are hard to manage. Characters are restricted to the range [a-zA-Z0-9] to improve readability and prevent confusion and spam registrations caused by special characters.