---
eip: 5298
label: ERC-5298
title: ENS Trust to hold NFTs under ENS name
status: Stagnant
type: Standards Track
category: ERC
created: 2022-07-12
requires: 137, 721, 1155
official: https://eips.ethereum.org/EIPS/eip-5298
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5298.md
canonical: https://eips.huatuo.xyz/eip-5298/
lang: en
tldr: "A 'trust' contract that holds NFTs on behalf of an ENS name, so tokens can be sent to someone's name even before they have a wallet, and whoever owns the name later claims them."
tags: [ens, nft, custody, erc721, erc1155]
---

# ERC-5298: ENS Trust to hold NFTs under ENS name

> An interface for a smart contract acting as a "trust" that holds tokens by ENS name.

**TL;DR:** A 'trust' contract that holds NFTs on behalf of an ENS name, so tokens can be sent to someone's name even before they have a wallet, and whoever owns the name later claims them.

## What problem does it solve?

To receive an NFT today you need a wallet address first, and the token is tied to that address. If you want to gift an NFT to `alice.eth` before she has set up a wallet, or tie ownership to a name rather than to a specific key, there is no standard way to do it.

ERC-5298 decouples NFT ownership from wallet addresses by letting a contract hold tokens for an [ENS](/eip-137/) node. The current owner of that ENS name can later claim the token to any address.

## How it works

A compliant "ENS trust" contract:

1. Accepts [ERC-721](/eip-721/) and [ERC-1155](/eip-1155/) tokens by implementing the standard receiver hooks. The sender passes the target **ENS node** (namehash) in the `data` argument of `safeTransferFrom`, and the trust records the token under that node.
2. Exposes one function:

   ```solidity
   function claimTo(address to, bytes32 ensNode, address operator, uint256 tokenId) external payable;
   ```

3. `claimTo` MUST check that `msg.sender` owns the ENS node (or is approved in an implementation-specific way), then calls `safeTransferFrom` on the token contract to send the token to `to`.

Any ENS node is allowed. The spec does not define getters or setters for the ENS registry address or for listing holdings.

## Sample code

A simplified ERC-721-only trust (illustrative, unaudited):

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IENS { function owner(bytes32 node) external view returns (address); }
interface IERC721 { function safeTransferFrom(address, address, uint256) external; }

contract ENSTrust {
    IENS public immutable ens;
    // token contract => tokenId => ENS node it is held for
    mapping(address => mapping(uint256 => bytes32)) public heldFor;

    constructor(IENS _ens) { ens = _ens; }

    function onERC721Received(address, address, uint256 tokenId, bytes calldata data)
        external returns (bytes4)
    {
        require(data.length == 32, "data must be ENS node");
        heldFor[msg.sender][tokenId] = bytes32(data); // msg.sender = token contract
        return this.onERC721Received.selector;
    }

    function claimTo(address to, bytes32 node, address token, uint256 tokenId) external payable {
        require(ens.owner(node) == msg.sender, "not ENS owner");
        require(heldFor[token][tokenId] == node, "not held for node");
        delete heldFor[token][tokenId];
        IERC721(token).safeTransferFrom(address(this), to, tokenId);
    }
}
```

Sending: `nft.safeTransferFrom(me, trust, tokenId, namehash("alice.eth"))`.

## Things to know

- Status: **Stagnant**. Security considerations in the spec are marked "Needs discussion".
- Whoever controls the ENS name controls the tokens. An expired, transferred or wrapped name changes who can claim; for wrapped names, `ENS.owner()` returns the wrapper contract, so check how your implementation resolves ownership.
- The spec's reference code warns against decoding raw `data` as a node in production; use a clearly typed encoding instead.
- For giving an NFT its own account rather than tying it to a name, see [ERC-6551](/eip-6551/).


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-5298
