ERC-5753 Lockable NFT extension (Lockable Extension for EIP-721)
Stagnant · NFTs & multi-token · created 2022-10-05
Adds a lock function that prevents only transfers while keeping the NFT in the owner's wallet, allowing the NFT to still be used during collateral, rental, or installment transactions.
Why it is needed
In DeFi, depositing fungible tokens like ETH as collateral in a lending contract works naturally. But NFTs often derive their value only while held in a wallet, such as for PFP-based Twitter verification, gaining access to a Discord server, or use in a P2E game. With the conventional approach of transferring an NFT to a lending contract or rental service as collateral, none of these uses are available during the loan period. There is also a risk that holding blue-chip NFTs only in a wallet like MetaMask without a cold wallet could lead to them being immediately transferred and stolen if hacked. Without a standard way to block only transfers while keeping ownership and usage intact, every service has to build its own ad hoc lock logic, which also hurts compatibility with ecosystem tools.
What to implement
event Lock (address indexed unlocker, uint256 indexed id);: An event emitted when a token is locked and an unlocker address is designated.event Unlock (uint256 indexed id);: An event emitted when a token's lock is released.function lock(address unlocker, uint256 id) external;: Locks the token and grants unlock authority to the designated unlocker address.function unlock(uint256 id) external;: Unlocks the token.function getLocked(uint256 tokenId) external view returns (address);: Returns the unlocker address for the given tokenId. If it is address(0), the token is not locked.
In depth
Lock state and the getLocked return value
If a token is locked, getLocked MUST return the unlocker address that holds unlock authority, and if it is not locked, it MUST return address(0). If a user calls lock(address(1), tokenId), the token can be locked permanently. Since address(1) is an address no one holds the private key to, the token can never be unlocked again afterward.
Blocking transfers and approvals
While a token is locked, all EIP-721 transfer functions must revert except for transactions initiated by the unlocker. Calls to approve for the same token must also revert. getApproved, on the other hand, must return the unlocker address, so the unlocker can still transfer the token through the standard approval flow.
Preventing re-locking and automatic unlocking
Calling lock again on an already-locked token must revert, even if the same unlocker address is passed as the argument. Conversely, if the unlocker transfers a locked token, the token must automatically become unlocked once the transfer completes.
How marketplaces should handle this
Marketplaces must call getLocked to check whether a token is locked. Since a locked token represents an order that cannot be settled, it must be hidden from listings and must not be exposed as available for sale.
ERC165 interface identifier
A contract that supports this extension must return true when supportsInterface is called with 0x72b68110. This lets other contracts or marketplaces check in advance whether Lockable extension support is present.
Authorization checks in the reference implementation
In the reference implementation, the lock function only operates after confirming that the caller is either the token owner or an operator delegated via isApprovedForAll. Internally, it grants transfer authority to the unlocker by calling _approve(unlocker, id), reusing the EIP-721 approve flow as is.
Note on proposal status
This proposal's status is Stagnant, meaning it is a draft that is no longer under active discussion and has paused. Since the specification is not a finalized standard, its current status should be checked before actual adoption.
Things to watch out for
- Ensuring the unlocker can actually unlock: You must confirm that the address or contract designated as the unlocker can actually unlock the token under all circumstances. Otherwise, the token could end up permanently locked.
- Choosing the transfer function to prevent reentrancy: Services like rentals, which transfer a token to a temporary owner and then lock it, should use transferFrom instead of safeTransferFrom to avoid reentrancy.
- No MEV-related considerations: Since locking and unlocking can only be performed by authorized parties, this standard itself has no MEV-related considerations.