ERC-6997 ERC-721 with a Transfer Validation Step (ERC-721 with transaction validation step.)
Review · NFTs & multi-token · created 2023-05-07
An ERC-721 extension that locks transfers and approvals of an NFT into a pending validation state instead of executing them immediately, requiring a separate validation step before they actually take effect. This prevents an NFT from being immediately drained even if a wallet is compromised.
Why it is needed
On Ethereum, transfers and approvals of NFTs (unique digital assets recorded on the blockchain) execute instantly with a single signature from the owner. If a wallet's private key leaks or a user signs a malicious request via phishing, there is no way to reverse the NFT transfer. The very structure that gives the blockchain its strength, placing full responsibility for data on the user, also becomes its weakness. There have been many real cases of NFT theft, and the conventional way to prevent theft, moving NFTs into a cold wallet (a storage wallet not connected to the internet), makes NFTs inconvenient to use. By placing a validation step before every transfer and approval, a thief would need to obtain both the user's address and the validator address at the same time, making for a much stronger anti-theft system.
What to implement
event ValidateTransfer(address indexed from, address to, uint256 indexed tokenId, uint256 indexed transferValidationId);: An event emitted when a new transfer validation request is created. It announces the sending address, receiving address, token ID, and validation request ID.event ValidateApproval(address indexed owner, address approve, uint256 tokenId, bool indexed approveAll, uint256 indexed approvalValidationId);: An event emitted when a new approval validation request is created. It announces whether it is a full approval (approveAll) along with the validation request ID.function isValidatorContract() external view returns (bool);: Returns true to indicate whether this contract is an ERC-721 that supports the validation step.function transferValidation(uint256 transferId) external view returns (TransferValidation memory);: Looks up the transfer validation information (sending address, receiving address, token ID, validation status) for a given transfer validation ID.function approvalValidation(uint256 approvalId) external view returns (ApprovalValidation memory);: Looks up the approval validation information (owner, approved party, token ID, whether it is a full approval, validation status) for a given approval validation ID.function totalTransferValidations() external view returns (uint256);: Returns the total number of transfer validation requests created so far.function totalApprovalValidations() external view returns (uint256);: Returns the total number of approval validation requests created so far.
In depth
Rules for locking transfers and approvals
Any operation that changes NFT ownership, such as transferFrom/safeTransferFrom, SHALL create a pending TransferValidation and emit the ValidateTransfer event, and SHALL NOT transfer ownership. Likewise, any operation that turns on an approval, such as approve/setApprovalForAll, SHALL create an ApprovalValidation and emit the ValidateApproval event, and SHALL NOT turn on the approval. The actual ownership transfer and approval activation are performed by the respective operations that validate each request.
An exception for transfers by approved accounts
If a transfer is called not by the owner but by an already-approved account, it MUST execute immediately without validation. This rule exists to accommodate every current marketplace that requires an approval in order to move an NFT directly. In other words, since validation has already occurred at the approval step, a transfer based on that approval works exactly as before.
Validation is one-time
When validating a TransferValidation or ApprovalValidation, the valid field MUST be set to true, and the same request MUST NOT be validated again. The operation that validates a TransferValidation transfers NFT ownership, and the operation that validates an ApprovalValidation turns on the approval. In the reference implementation, attempting to validate a request that is already valid reverts, and for individual approvals it also checks whether the owner at the time of the request still holds the token.
Interface and implementation requirements
The TransferValidation struct holds the from, to, tokenId, and valid fields, and the ApprovalValidation struct holds the owner, approve, tokenId, approveAll, and valid fields. The isValidatorContract() function MUST be implemented as public. transferValidation(uint256 transferId) and approvalValidation(uint256 approveId) MAY be implemented as public or external, and totalTransferValidations() and totalApprovalValidations() MAY be implemented as pure or view.
The validation method is not specified by the standard
This standard only defines the validation functionality and does not specify how it should be used. The validation operations are defined as internal, and it is up to the implementer to decide what scheme to validate with. For example, a single validator address could be connected to a dapp to let a user manage their validation requests, and this validator could be used for every NFT or only for some users. It could also be implemented as a wrapper contract around an existing ERC-721, allowing a one-to-one conversion with existing NFTs. Any third-party protocol can define any way it wants to call these validation functions.
Backward compatibility
This standard is an extension of ERC-721 and is compatible with every operation except transferFrom/safeTransferFrom/approve/setApprovalForAll. These four operations are redefined to create a validation request instead of transferring ownership or turning on an approval. In the reference implementation, a call that turns off full approval (setApprovalForAll with approved set to false) executes immediately without validation.
Proposal status
This proposal is currently in Review status. As a standard still under review, its content may change.
Things to watch out for
- Protecting the validation operations: The operations that validate TransferValidation and ApprovalValidation must be protected with the maximum security required by the system they are applied to. This is valid whether the system uses a single validator address to validate transactions or lets each user choose their own validator address. In any case, no address should be able to execute validation without the permission of the chosen system. This is the core of its security.