ERC-7564 Contract wallet NFT management (Contract wallet management NFT)
Draft · Accounts & wallets · created 2023-11-21
An interface that lets smart contract wallets manage NFT approvals and transfers directly within the wallet. Approvals can be set at the level of a single NFT, an entire contract, or all NFTs.
Why it is needed
Currently, each NFT contract sets its own rules for NFT approval and transfer. Ordinary wallets (externally owned accounts, EOAs) cannot store state or code, so users must call approve directly on the NFT contract and follow whatever method that contract defines. Under this structure, users have difficulty controlling risks inherent in existing ERC-721 contracts, such as over-approval, granting broader permissions than necessary. There is also no standard way to attach conditions or expirations to an approval, to insert custom checks before or after a transfer, or to approve or transfer multiple items at once. This proposal places NFT approval and transfer functionality inside the smart contract wallet, which can hold state and code, in order to shift control over approval management from the NFT contract to the user's wallet.
What to implement
function nftApprove(address _asset, address _operator, uint256 _tokenId) external;: Approves an operator to take a specific NFT from the wallet. Emits an NftApproval event.function nftSetApprovalForOneAll(address _asset, address _operator, bool _approved) external;: Sets or revokes operator approval for all NFTs of one asset contract. Emits an NftApprovalForOneAll event.function nftSetApprovalForAllAll(address _operator, bool _approved) external;: Sets or revokes operator approval for all NFTs held by the wallet. Emits an NftApprovalForAllAll event.function nftGetApproved(address _asset, address _operator, uint256 _tokenId) external view returns (bool _approved);: Checks whether an operator is approved for a specific NFT.function nftIsApprovedForOneAll(address _asset, address _operator) external view returns (bool _approved);: Checks whether an operator is approved for all NFTs of one asset contract.function nftIsApprovedForAllAll(address _operator) external view returns (bool _approved);: Checks whether an operator is approved for all NFTs.function nftTransfer(address _asset, address _to, uint256 _tokenId) external returns (bool _success);: Transfers an NFT held by the wallet to a specified address and returns whether it succeeded. The function must call that NFT contract's transfer() internally.
In depth
A structure that shifts approval control to the wallet
EOA wallets have no state or code storage, but smart contract wallets do. This proposal uses that programmability to have NFT asset allocation and management, especially approval settings, handled by the user's contract wallet rather than the NFT asset contract. The source text presents this as a way to avoid some of the risks inherent in existing ERC-721 contracts. It also explains that this ERC can be used as an ERC-4337-based extension or wallet plugin in the account abstraction direction.
Three-tier approval functions
Approval scope is divided into three levels. nftApprove(_asset, _operator, _tokenId) approves a single specific NFT. nftSetApprovalForOneAll(_asset, _operator, _approved) approves or revokes all NFTs of one asset contract. nftSetApprovalForAllAll(_operator, _approved) approves or revokes all NFT assets in the wallet at once. Each must emit the NftApproval, NftApprovalForOneAll, and NftApprovalForAllAll events respectively, carrying the asset address, owner, operator, and the tokenId or approval status.
Approval query functions
There are three query functions paired with the setters. nftGetApproved(_asset, _operator, _tokenId) returns whether a specific NFT is approved, nftIsApprovedForOneAll(_asset, _operator) returns whether an entire asset contract is approved, and nftIsApprovedForAllAll(_operator) returns whether all NFTs are approved, each as a bool value (_approved). All are view functions.
Behavior rules of nftTransfer
nftTransfer(_asset, _to, _tokenId) must call transfer() on the corresponding NFT asset contract inside the function. If the caller is not the wallet itself, it must verify and update the approval, and return success as a bool (_success). Users can extend functionality by adding hook functions before and after nftTransfer, and implementing an nftReceive function is optional. Wallets may also optionally support batch approvals and batch transfers.
Design rationale
In existing ERC-721, an EOA interacts directly with the NFT contract and calls approve, but this proposal's functions allow finer control over NFT usage inside the wallet contract. Moving approval control to the user's wallet reduces risks such as excessive approvals and enables advanced approval strategies like conditional or time-limited approvals. It explains that batch operations handling multiple approvals or transfers at once improve efficiency, and custom logic (hooks) before and after transfers can add extra security checks or custom behavior.
Compatibility and requirements
A compliant contract must implement the ERC-165 interface. This ERC can be used as an extension of ERC-4337 and is backward compatible with ERC-4337. The original text explains that this wallet interface supports a separate simple NFT standard (referred to in the original as ERC-X, with the number still unassigned), and since ERC-721 is backward compatible with that standard, it can be compatible with all NFT management on existing markets.
A proposal still at the Draft stage
This ERC is a proposal in Draft status created on November 21, 2023. As it is still a draft whose content may change, function names and detailed rules may be revised. Incomplete parts remain, such as the ERC-165 identifier value being left blank in the original code comments.