ERC-5298 ENS Name Based NFT Custody Trust (ENS Trust to hold NFTs under ENS name)
Stagnant · NFTs & multi-token · created 2022-07-12
An interface for a trust contract that receives and holds NFTs (ERC-721/1155) under an ENS name instead of a wallet address. The name owner can later withdraw the token to an address of their choice.
Why it is needed
Until now, receiving an NFT required first obtaining a wallet address. Because NFT ownership is tied directly to a wallet address, there was no way to send a token if the recipient's address was unknown or they did not yet have a wallet. This standard separates NFT ownership from wallet addresses through a trust contract that holds NFTs on behalf of the ENS name owner. Tokens are held in the trust contract keyed by ENS node, and only the owner of that ENS name can later withdraw the token to an address of their choice.
What to implement
function claimTo(address to, bytes32 ensNode, address operator, uint256 tokenId) payable external;: A function called by the owner of an ENS node (or an entity approved on that domain) to withdraw a token held in the trust contract to address to.
In depth
Interface Requirements
A compliant contract must implement ERC721TokenReceiver as defined in EIP-721. It must also implement the IERC_ENS_TRUST interface, which inherits from ERC721Receiver and ERC1155Receiver, including the function claimTo(address to, bytes32 ensNode, address operator, uint256 tokenId) payable external.
Ownership verification in claimTo
claimTo must verify that msg.sender is the owner of the ENS node identified by bytes32 ensNode (and, depending on the implementation, may also verify approval from that domain). Once verified, the contract must call the safeTransferFrom function of EIP-721 or EIP-1155.
No restriction on ENS nodes
Any ensNode is allowed. That is, no restriction is placed on which ENS nodes the trust contract can receive and hold.
Why ENS was chosen
ENS was chosen because it is an already well-established namespace of ownership. That said, this standard could also be compatible with other scoped ownership namespaces. A getter or setter for ensRoot was also not exposed, since it was considered out of scope for this EIP.
Backward compatibility
No backward compatibility issues have been identified for this standard.
Reference implementation example
The reference implementation contract, FirstENSBankAndTrust, manages the ENS registry address via getENS/setENS. onERC721Received checks that the length of the incoming data is 32 bytes, extracts the ENS node from it, and performs internal bookkeeping via addToHolding. However, a code comment warns that extracting the bytes32 directly from data this way is only for demonstration purposes, and that a production environment should use a struct that clearly identifies the data as ENS data. claimTo checks whether the owner of that node in the ENS registry matches msg.sender, then clears the record via removeFromHolding and transfers the token to the recipient via safeTransferFrom.
Test scenario
The test code proceeds as follows. A token is minted to charlie, and charlie calls safeTransferFrom to send the token to the ENS trust contract, placing the ENS node for bob.xinbenlvethsf.eth in data. When bob first calls claimTo, it is rejected because he is not yet the owner of that ENS node. After bob is set as the owner of that node in the ENS registry, calling claimTo again succeeds and he receives the token.
Proposal status
This proposal is currently in Stagnant status, meaning it is no longer being actively discussed and has stalled.