EIPs Explained

ERC-7644 · Draft · ERC · 2024-03-01

ERC-7644: ERC-721 Name Registry Extension

A draft ERC-721 extension that gives each token a unique, human-readable name (bytes32) that expires after a chosen duration, with lookups in both directions between names and token IDs.

What problem does it solve?

NFTs are identified by numeric token IDs, which mean nothing to people. Projects that use NFTs as memberships, profiles or game characters often want a username attached to each token, but every project builds its own naming scheme, so wallets and indexers cannot read names consistently.

ERC-7644 adds a small, standard naming layer inside an ERC-721 collection: each token can hold one name, names are unique within that contract, and each registration has an expiry so unused names eventually return to the pool rather than being hoarded forever.

How it works

The extension adds one event and four functions:

Function Purpose
setName(tokenId, name, duration) Assign or change a token's name, valid for duration seconds from now
nameOf(tokenId) The token's current name, or empty bytes32 if none or expired
tokenIdOf(name) The token holding a name, or 0 if none (the reference implementation reverts on expired names)
nameInfo(name) Token ID and expiry timestamp for an active name

NameChanged(tokenId, oldName, newName, expiryDate) lets indexers follow changes.

The rules: a name must not be held by another token with a registration that has not expired. Who may call setName is left to the use case; the reference implementation lets the token owner do it. Because the name is stored against the token ID, it travels with the NFT when the token is transferred.

The reference implementation also shows anti-abuse limits the authors recommend: a maximum duration (10 years there), a minimum interval between renames (1 day), and the security section suggests restricting names to 3–32 characters of [a-zA-Z0-9].

Sample code

Setting and resolving a name with ethers v6:

import { Contract, encodeBytes32String, decodeBytes32String } from "ethers";

const abi = [
  "function setName(uint256 tokenId, bytes32 name, uint256 duration)",
  "function nameOf(uint256 tokenId) view returns (bytes32)",
  "function nameInfo(bytes32 name) view returns (uint256 tokenId, uint256 expiryDate)",
  "event NameChanged(uint256 indexed tokenId, bytes32 oldName, bytes32 newName, uint256 expiryDate)",
];
const nft = new Contract(collectionAddr, abi, signer);

const name = encodeBytes32String("alice");          // must be <= 31 bytes for this helper
const ONE_YEAR = 365n * 24n * 60n * 60n;
await (await nft.setName(42n, name, ONE_YEAR)).wait();

const raw = await nft.nameOf(42n);
console.log(decodeBytes32String(raw));              // "alice"

const [tokenId, expiry] = await nft.nameInfo(name);
console.log(tokenId, new Date(Number(expiry) * 1000));

Things to know

  • Status: Draft.
  • Names are unique only within one NFT contract. This is not a global naming system like ENS (EIP-137).
  • Token ID 0 is also the "not found" value of tokenIdOf, so collections that mint token 0 should check nameInfo or nameOf instead.
  • Names are raw bytes32. The standard does not define encoding, case-folding or character rules; normalise input (for example lowercase ASCII) in your app to avoid look-alike names.
  • Expiry is checked against block.timestamp; after expiry the name can be claimed by any other token.

#nft #erc721 #names #usernames #registry

Details

Authors
Chen Liaoyuan (@chenly)
Status
Draft
Type
Standards Track / ERC
Created
2024-03-01
Requires

Machine-readable: Markdown · JSON