ERC-4799 · Stagnant · ERC · 2022-02-13
ERC-4799: Non-Fungible Token Ownership Designation Standard
Lets a contract that holds an NFT in escrow point to the NFT whose owner should be treated as the real owner, so wrapped, rented or collateralized NFTs keep delivering their utility to the right person.
What problem does it solve?
Many NFTs carry utility: access to an event, airdrops, membership. Apps deliver that utility to whoever ownerOf(tokenId) returns. The moment you put the NFT into another contract (to rent it out, fractionalize it, use it as collateral or add features), ownerOf returns the contract, and the human behind it loses the perks.
ERC-4799 gives such wrapper contracts a standard way to say "the real, designated owner of this NFT is whoever owns that other NFT", so apps can follow the chain and reward the right address without the original NFT losing its authenticity.
How it works
Two interfaces:
IERC4799NFT: the minimal "essence of an NFT", justownerOf(tokenId)and aTransferevent. Every ERC-721 token already satisfies it.IERC4799: implemented by an ownership designation contract (ODC). Its key functiondesignatedTokenOf(sourceContract, sourceTokenId)returns(targetContract, targetTokenId). AnOwnershipDesignationevent is emitted when a designation is set.
Resolution rules for clients:
- Call
ownerOfon the original NFT. - If the owner is a contract that supports
IERC4799(checked via ERC-165), ask it for the designated token and repeat on that token. - Stop at an address that is not an ODC. That address is the designated owner.
A designation only counts if the ODC really owns the source NFT according to the source contract, so every NFT still has exactly one designated owner. Clients must never send utility to the ODC itself. Chains can be nested, forming a directed acyclic graph.
Sample code
Resolving the designated owner, with a depth limit (adapted from the spec's reference helper):
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
interface IERC4799NFT { function ownerOf(uint256 tokenId) external view returns (address); }
interface IERC4799 {
function designatedTokenOf(IERC4799NFT src, uint256 srcId)
external view returns (IERC4799NFT, uint256);
}
contract DesignatedOwner {
function designatedOwnerOf(IERC4799NFT nft, uint256 id, uint256 maxDepth)
public view returns (address owner)
{
owner = nft.ownerOf(id);
if (ERC165Checker.supportsInterface(owner, type(IERC4799).interfaceId)) {
require(maxDepth > 0, "depth limit exceeded");
(nft, id) = IERC4799(owner).designatedTokenOf(nft, id);
return designatedOwnerOf(nft, id, maxDepth - 1);
}
}
}
Things to know
- Status is Stagnant: the proposal is not progressing and the ERC-165 interface ID is still marked TODO in the spec.
- Always resolve with a
maxDepth: a malicious actor could create very long or cyclical chains to make lookups run out of gas. - The scheme only helps if utility providers (airdrop scripts, gating tools) actually follow designations.
- Related approaches: ERC-4907 adds a separate time-limited "user" role to an NFT, and ERC-6551 gives each NFT its own account.