ERC-4799 NFT ownership delegation standard (Non-Fungible Token Ownership Designation Standard)
Stagnant · NFTs & multi-token · created 2022-02-13
Even when an NFT is held in escrow by another contract, this lets the true owner of that NFT be designated and queried in a standardized way.
Why it is needed
When an NFT is wrapped inside another contract to add new functionality, the original NFT's owner field changes to the wrapping contract's address. This means services that want to give benefits to the original NFT's owner, such as event tickets, airdrops, or residency rights, no longer know who to give them to. Previously, this kind of complex ownership structure had to be designed into the contract from the moment the NFT was issued, and there was no way to later attach features like lending, collateralization, or fractional ownership to an NFT that had already been issued and was already circulating. The moment wrapping happened, the original NFT lost the trust and benefit access it had.
What to implement
function ownerOf(uint256 tokenId) external view returns (address);: Returns the current owner address of a specific NFT (tokenId). A token assigned to the zero address is considered invalid and the query errors.function designatedTokenOf(IERC4799NFT sourceContract, uint256 sourceTokenId) external view returns (IERC4799NFT, uint256);: Returns the contract address and tokenId of the target NFT to which the source NFT is delegating ownership.
In depth
The IERC4799NFT Interface
A minimal interface that inherits ERC-165 and defines only the Transfer event and the ownerOf function. Nearly every already-deployed NFT contract, including ERC-721, implicitly implements this interface. ownerOf returns the owner address for a tokenId, and a token assigned to the zero address is considered invalid and reverts on lookup.
IERC4799 and designatedTokenOf
An Ownership Designation Contract (ODC) implements the function designatedTokenOf(sourceContract, sourceTokenId) to map a single source NFT to one target contract and tokenId. Whenever this mapping changes, it emits an OwnershipDesignation event. Through this function, the ODC expresses the delegated ownership it believes to hold.
Verifying the Authenticity of Ownership
Delegated ownership is valid only if the ODC is actually registered as the result of ownerOf for the source NFT. Clients must verify this by querying the source contract directly. A client that follows this specification must not distribute benefits to the ODC address itself, but to the owner of the target token that designatedTokenOf points to.
DAG Structure and the End of the Chain
Each source NFT points to exactly one target NFT, and as NFTs link together in sequence they form a directed acyclic graph (DAG). The address at the terminal end of this chain becomes the delegated owner of every NFT belonging to that chain.
Backward Compatibility with ERC-721
Since IERC4799NFT is an interface that IERC721 implicitly extends, every already-deployed ERC-721 contract satisfies the IERC4799NFT requirements as is, with no additional code. As a result, the ERC-4799 standard, which wraps IERC4799NFT, is fully backward compatible with ERC-721.
Reference Implementation: ERC721Composable
The reference implementation in the original text, ERC721Composable, restricts calls to designateToken to only the owner of the source NFT or an address approved via getApproved to designate a target. In onERC721Received, it re-approves the received token back to the sending address and exposes the IERC4799 and IERC721Receiver interfaces through supportsInterface.
Recursive Lookup via designatedOwnerOf
The reference implementation's DesignatedOwner contract first obtains the current owner via tokenContract.ownerOf, and if that owner supports IERC4799 according to supportsInterface, it calls designatedTokenOf to move to the next token. This process repeats recursively up to maxDepth times to find the final owner.
Proposal status
This standard is currently in Stagnant status, a proposal that is no longer under active discussion and has stalled.
Things to watch out for
- Long or Cyclical Ownership Chains: If a malicious user creates an excessively long or cyclical ownership chain, an application looking up the delegated owner could exhaust all its gas and fail to operate. To prevent this, clients must set a maxDepth value during lookup and halt the operation after traversing the chain a certain number of times.