ERC-4494 ERC-721 Signature-based approval (Permit) (Permit for ERC-721 NFTs)

Stagnant · NFTs & multi-token · created 2021-11-25

A standard that lets an NFT owner delegate usage rights for a given NFT to a specific address using only an off-chain signature (EIP-712), without an on-chain approve transaction.

Why it is needed

In existing ERC-721, letting another address (a marketplace, a lending platform, etc.) move your NFT on your behalf requires two transactions: first sending an approve transaction, then having the counterparty call transferFrom. This is a cumbersome flow in which the user has to pay gas twice and a time gap opens up between approval and actual use. ERC-20 had a way to solve this problem with ERC-2612 permit, but ERC-721 could not simply adopt it because its structure differs: it deals with individual tokenIds rather than quantities, and each token's owner can change. Without this standard, NFT owners must bear the gas cost and wait time of an on-chain approve transaction every time, and wallets or platforms have no way to offer a gasless approval flow for NFTs.

What to implement

In depth

Conditions under which the permit function sets the approval

For a permit(spender, tokenId, deadline, sig) call to set spender as approved for tokenId and emit an Approval event, all of the following must hold: the current block timestamp must be at or before deadline, the owner of tokenId must not be the zero address, nonces[tokenId] must equal the nonce used in the signature, and sig must be a valid secp256k1 or EIP-2098 signature from the owner. This condition is valid only while the owner still holds that tokenId.

Nonce and replay protection

nonces[tokenId] must increment every time that tokenId is transferred (that is, whenever the owner changes). This differs from ERC-2612, where the nonce increments when a permit is created: once the tokenId passes to a new owner, a signature made by the previous owner can no longer be replayed.

DOMAIN_SEPARATOR and the EIP-712 message structure

The message that gets signed takes the form keccak256(0x1901 || DOMAIN_SEPARATOR || structHash), where structHash is the hash of a struct typed as Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline). DOMAIN_SEPARATOR is defined per EIP-712 and typically includes the name, version, chainId, and contract address, preventing replay attacks against other contracts or chains.

Signature format: why bytes

ERC-2612 takes signatures split into v, r, and s, but this standard takes a single variable-length bytes value. This choice makes it easy to support not only traditional 65-byte signatures but also 64-byte EIP-2098 compact signatures, since EIP-2098 signatures cannot be cleanly split into and reconstructed from r, s, v.

EIP-165 interface registration

The interface ID for this standard is 0x5604e225, and implementing contracts must return true from a call to supportsInterface(0x5604e225). Since ERC-721 already requires EIP-165, registering this ID lets other contracts or services easily check whether a given NFT contract supports this permit standard.

Differences from existing implementations (Uniswap v3)

Some ERC-721 contracts, such as Uniswap v3, already use permit-like structures, but they differ from this standard. In existing implementations, the permit structure is keyed on owner, the nonce increments at the time the permit is created, the permit function must be called by the NFT owner (the address set as owner), and the signature is split into r, s, v. This standard is deliberately designed to differ on all four of these points.

Proposal status: Stagnant

This proposal is in Stagnant status, meaning discussion has stalled and is no longer progressing. Its content may change or it may never become a final standard.

Things to watch out for

Original ERC · ← ERCs