EIPs Explained

ERC-7561 · Draft · ERC · 2023-10-29

ERC-7561: Simple NFT, Simplified ERC-721

A draft stripped-down NFT standard for smart contract wallets that keeps only balanceOf, ownerOf and transferFrom, leaving approvals and safe transfers to the wallet instead of the token.

What problem does it solve?

ERC-721 was designed around EOA wallets, which have no code. To let a marketplace move your NFT, the token contract itself stores approvals (approve, setApprovalForAll). Forgotten "approve all" permissions are a well-known source of stolen NFTs, and safeTransferFrom callbacks add complexity and reentrancy surface.

Smart contract wallets can handle permissions themselves: session keys, spending rules, batched calls. ERC-7561 argues the token should therefore be as small as possible and leave everything else to the wallet.

How it works

A compliant contract implements only:

Member Purpose
balanceOf(owner) Number of NFTs an address holds
ownerOf(tokenId) Current owner
transferFrom(from, to, tokenId) Move a token
Transfer event Same signature as ERC-721, so indexers keep working

Removed from ERC-721: approve, getApproved, setApprovalForAll, isApprovedForAll, and both safeTransferFrom variants. In the reference implementation transferFrom requires from == msg.sender: only the owner (typically a smart wallet) can move its tokens. If a marketplace needs to move an NFT, the user's wallet executes that transfer itself, for example as part of a batched, user-signed operation.

The authors describe it as "forward compatible" with ERC-721: an ERC-721 token already offers every function in this interface.

Sample code

Minimal implementation following the spec's interface:

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

contract SimpleNFT {
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    mapping(uint256 => address) private _owners;
    mapping(address => uint256) private _balances;

    function balanceOf(address owner) external view returns (uint256) {
        require(owner != address(0), "zero address");
        return _balances[owner];
    }

    function ownerOf(uint256 tokenId) public view returns (address owner) {
        owner = _owners[tokenId];
        require(owner != address(0), "nonexistent");
    }

    function transferFrom(address from, address to, uint256 tokenId) external {
        require(from == msg.sender, "only owner");        // no approvals in this standard
        require(to != address(0), "zero address");
        require(ownerOf(tokenId) == from, "not owner");
        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;
        emit Transfer(from, to, tokenId);
    }
}

Things to know

  • Status: Draft.
  • Existing marketplaces and DeFi protocols rely on approvals and safeTransferFrom. A token following only this interface will not work with them; the spec's own security section acknowledges incompatibility with existing dapps.
  • An EOA can still hold these tokens and call transferFrom directly, but loses delegation entirely unless it uses a smart account (for example via EIP-7702 or ERC-4337).
  • Without safeTransferFrom, tokens can be sent to contracts that cannot move them, and they will be stuck.
  • The reference code notes an ERC-165 identifier of 0xc1b31357 for its interface.

#nft #erc-721 #smart-wallet #account-abstraction

Details

Authors
Xiang (@wenzhenxiang), Ben77 (@ben2077), Mingshi S. (@newnewsms)
Status
Draft
Type
Standards Track / ERC
Created
2023-10-29
Requires

Machine-readable: Markdown · JSON