Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-4799 proposes a mechanism for designating the owner of another NFT as the effective owner of an NFT.

This article translates, summarizes, and explains the original proposal.

Other EIP proposals are covered here.

Overview

ERC-4799 defines an interface through which a smart contract holding an NFT in escrow can designate another NFT whose owner is treated as the effective owner of the escrowed asset.

This interface enables NFT ownership relationships to be modeled as a directed acyclic graph (DAG), provided that applications prevent or reject cycles. It allows applications to extend existing NFTs with mechanisms such as wrapping, lending, collateralization, or fractional ownership while preserving the identity and provenance of the original NFT. Those additional features require their own application logic.

What is a directed acyclic graph?

A directed acyclic graph, or DAG, consists of nodes connected by directed edges. It contains no directed path that returns to its starting node.

Example: ordering tasks

Suppose a project requires the following tasks.

  • A: Prepare a document.
  • B: Review the document after A.
  • C: Print the document after B.

The dependencies can be represented as follows.

text
A → B → C

A precedes B, and B precedes C. The edges follow a direction without forming a cycle. This is an example of a DAG.

Properties of a DAG
  • Directed
    • Edges have a defined direction.
  • Acyclic
    • Following directed edges cannot lead back to the starting node.
  • Dependency structure
    • A DAG can express dependencies and hierarchical relationships, although it need not form a strict tree.

Motivation

Many NFTs provide some form of utility to their holders, such as apartment occupancy rights, access to event tickets, or eligibility for token airdrops.

For applications relying solely on the standard NFT ownership interface, the directly verifiable owner is the address returned by the token contract. Utility distribution is therefore often limited to that address. To support more complex ownership arrangements, such as lending or collateralization, developers may need to build additional logic into the original NFT contract or have applications recognize external contracts. This limits the options available for extending NFTs that have already been issued.

ERC-4799 aims to define more flexible ownership relationships for existing NFTs through separate contracts. This makes new applications possible without modifying the original asset.

Wrapping an NFT ordinarily involves depositing it into another contract. That contract becomes the onchain owner, potentially preventing the original user's address from receiving utility associated with the NFT.

ERC-4799 gives compatible external applications a standardized way to resolve the designated owner of a wrapped NFT. This allows applications to recognize the original asset's identity and utility while supporting additional functionality. Applications that only call the original token's ownerOf function will still see the escrow contract.

Specification

Interfaces

IERC4799NFT.sol
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

interface IERC4799NFT is IERC165 {
    /// @dev This emits when ownership of any NFT changes by any mechanism.
    ///  This event emits when NFTs are created (`from` == 0) and destroyed
    ///  (`to` == 0). Exception: during contract creation, any number of NFTs
    ///  may be created and assigned without emitting Transfer. At the time of
    ///  any transfer, the approved address for that NFT (if any) is reset to none.
    event Transfer(
        address indexed from,
        address indexed to,
        uint256 indexed tokenId
    );

    /// @notice Find the owner of an NFT
    /// @dev NFTs assigned to zero address are considered invalid, and queries
    ///  about them throw
    /// @param tokenId The identifier for an NFT
    /// @return The address of the owner of the NFT
    function ownerOf(uint256 tokenId) external view returns (address);
}
IERC4799.sol
/// @title ERC-4799 Non-Fungible Token Ownership Designation Standard
/// @dev See https://eips.ethereum.org/EIPS/eip-4799
/// Note: the ERC-165 identifier for this interface is [TODO].

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "./IERC4799NFT.sol";

interface IERC4799 is IERC165 {
    /// @dev Emitted when a source token designates its ownership to the owner of the target token
    event OwnershipDesignation(
        IERC4799NFT indexed sourceContract,
        uint256 sourceTokenId,
        IERC4799NFT indexed targetContract,
        uint256 targetTokenId
    );

    /// @notice Find the designated NFT
    /// @param sourceContract The contract address of the source NFT
    /// @param sourceTokenId The tokenId of the source NFT
    /// @return (targetContract, targetTokenId) contract address and tokenId of the parent NFT
    function designatedTokenOf(IERC4799NFT sourceContract, uint256 sourceTokenId)
        external
        view
        returns (IERC4799NFT, uint256);
}

Transfer

js
event Transfer(
    address indexed from,
    address indexed to,
    uint256 indexed tokenId
);

An event emitted when ownership of an NFT changes.

The event also reports minting, where from is the zero address, and burning, where to is the zero address. Token-specific approvals are reset when the NFT is transferred. As noted in the interface, initial assignments during contract construction may omit the event.

Parameters

  • from
    • The sending address.
  • to
    • The receiving address.
  • tokenId
    • The identifier of the NFT.

OwnershipDesignation

js
event OwnershipDesignation(
    IERC4799NFT indexed sourceContract,
    uint256 sourceTokenId,
    IERC4799NFT indexed targetContract,
    uint256 targetTokenId
);

An event emitted when a source NFT designates ownership to the owner of a target NFT.

The event indicates that an NFT identified by sourceContract and sourceTokenId is associated with another NFT identified by targetContract and targetTokenId. This establishes a designation link.

Parameters

  • sourceContract
    • The contract address of the source NFT.
  • sourceTokenId
    • The source NFT's token ID.
  • targetContract
    • The contract address of the target NFT.
  • targetTokenId
    • The target NFT's token ID.

ownerOf

js
function ownerOf(uint256 tokenId) external view returns (address);

Returns the owner of an NFT.

The function returns the current owner address of the specified token ID. Tokens assigned to the zero address are considered invalid, and queries for them revert.

Parameters

  • tokenId
    • The identifier of the NFT whose owner is being queried.

Return value

  • address
    • The NFT owner's address.

designatedTokenOf

js
function designatedTokenOf(IERC4799NFT sourceContract, uint256 sourceTokenId)
    external
    view
    returns (IERC4799NFT, uint256);

Returns the NFT to whose owner the source NFT's ownership has been designated.

Given a source NFT identified by sourceContract and sourceTokenId, the function returns the target NFT. A client can then resolve the target NFT's owner.

Parameters

  • sourceContract
    • The source NFT's contract address.
  • sourceTokenId
    • The source NFT's token ID.

Return values

  • IERC4799NFT
    • The target NFT's contract address.
  • uint256
    • The target NFT's token ID.

Additional requirements

  • Clients should resolve the owner of the designated NFT using its ownerOf function, rather than treating the ERC-4799 escrow contract as the final beneficiary.
  • Applications providing NFT utility should deliver it to the owner resolved at the end of the designation chain, subject to their own validation and authorization rules.

ERC-4799 standardizes the designation of ownership through another NFT. Compatible applications can use that relationship to extend conventional NFT wrapping without changing the identity of the underlying asset.

Rationale

To maximize compatibility, ERC-4799 defines a minimal common NFT interface, IERC4799NFT. Many existing NFT contracts, particularly ERC-721 contracts, already expose the functionality it requires. The ownerOf function expresses the relationship between a token identifier and its owner address.

This design allows additional functionality, including ownership designation, to be built around existing NFT assets without replacing their original contracts.

At the center of the proposal is IERC4799, the interface for an Ownership Designation Contract (ODC). Through designatedTokenOf, an ODC identifies another NFT whose owner is designated as the effective owner of the source NFT.

A designation is authoritative only when the ODC itself is the direct owner of the source NFT. This limits each source NFT to one authoritative designation at a given point in time, rather than allowing arbitrary third-party contracts to claim authority over it.

Compatibility

The IERC4799NFT interface is compatible with the relevant ownership-query and transfer-event functionality of ERC-721.

Reference Implementation

ERC721Composable.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.8.0 <0.9.0;

import "./IERC4799.sol";
import "./IERC4799NFT.sol";
import "./ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

contract ERC721Composable is IERC4799, IERC721Receiver {
    mapping(IERC4799NFT => mapping(uint256 => IERC4799NFT)) private _targetContracts;
    mapping(IERC4799NFT => mapping(uint256 => uint256)) private _targetTokenIds;

    function designatedTokenOf(IERC4799NFT sourceContract, uint256 sourceTokenId)
        external
        view
        override
        returns (IERC4799NFT, uint256)
    {
        return (
            IERC4799NFT(_targetContracts[sourceContract][sourceTokenId]),
            _targetTokenIds[sourceContract][sourceTokenId]
        );
    }

    function designateToken(
        IERC4799NFT sourceContract,
        uint256 sourceTokenId,
        IERC4799NFT targetContract,
        uint256 targetTokenId
    ) external {
        require(
            ERC721(address(sourceContract)).ownerOf(sourceTokenId) == msg.sender ||
            ERC721(address(sourceContract)).getApproved(sourceTokenId) == msg.sender, 
            "ERC721Composable: Only owner or approved address can set a designate ownership");
        _targetContracts[sourceContract][sourceTokenId] = targetContract;
        _targetTokenIds[sourceContract][sourceTokenId] = targetTokenId;
        emit OwnershipDesignation(
            sourceContract, 
            sourceTokenId,  
            targetContract,
            targetTokenId
        );
    }

    function onERC721Received(
        address,
        address from,
        uint256 sourceTokenId,
        bytes calldata
    ) external override returns (bytes4) {
        ERC721(msg.sender).approve(from, sourceTokenId);
        return IERC721Receiver.onERC721Received.selector;
    }

        function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return
            (interfaceId == type(IERC4799).interfaceId ||
            interfaceId == type(IERC721Receiver).interfaceId);
    }
}
DesignatedOwner.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.8.0 <0.9.0;

import "./IERC4799.sol";
import "./IERC4799NFT.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";

contract DesignatedOwner {
    function designatedOwnerOf(
        IERC4799NFT tokenContract,
        uint256 tokenId,
        uint256 maxDepth
    ) public view returns (address owner) {
        owner = tokenContract.ownerOf(tokenId);
        if (ERC165Checker.supportsInterface(owner, type(IERC4799).interfaceId)) {
            require(maxDepth > 0, "designatedOwnerOf: depth limit exceeded");
            (tokenContract, tokenId) = IERC4799(owner).designatedTokenOf(
                tokenContract,
                tokenId
            );
            return designatedOwnerOf(tokenContract, tokenId, maxDepth - 1);
        }
    }
}

The original examples are preserved above. The first records designation relationships, while the second recursively resolves the designated owner up to a depth limit. These examples are not a complete lending or escrow system. In particular, the first example authorizes the prior owner through an ERC-721 approval after receipt, and the second expects ERC-165 interface detection to work. The example's supportsInterface does not explicitly report IERC165 itself, which should be checked before using it with ERC165Checker. Production implementations also need explicit custody, release, and authorization rules.

Security Considerations

One of the main security risks in ERC-4799 is an excessively long or cyclic ownership designation chain.

A user could create a chain of designations spanning many NFTs, or construct a cycle that returns to a previously visited NFT.

An application attempting to resolve the final owner may then enter an unbounded loop, exhaust its gas budget, or otherwise fail to complete the operation.

Clients should impose a limit such as maxDepth. The maximum number of ownership designation links to follow must be established in advance, and resolution should stop if that limit is exceeded.

This bounds the work performed by the resolver. Clients can also explicitly detect cycles and treat unresolved or invalid chains as failures rather than assigning utility to an unverified address.

Citation

David Buckman (@davidbuckman), Isaac Buckman (@isaacbuckman), "ERC-4799: Non-Fungible Token Ownership Designation Standard [DRAFT]," Ethereum Improvement Proposals, no. 4799, February 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-4799.

Conclusion

ERC-4799 proposes a common interface for designating an NFT's effective owner through another NFT. It provides a way for compatible applications to resolve ownership relationships across escrow and wrapper contracts while preserving the original token's identity.

Questions are welcome through Twitter direct messages.

Twitter @cardene777

I also publish on the following platforms.

https://chaldene.net/