EIPs Explained

ERC-6454 · Final · ERC · 2023-01-31

ERC-6454: Minimal Transferable NFT detection interface

A one-function ERC-721 extension, isTransferable(tokenId, from, to), that lets wallets and marketplaces check whether an NFT can be moved before trying, covering soulbound and conditionally locked tokens.

What problem does it solve?

Some NFTs should stay with one account: achievement badges, credentials, in-game skills a player earned. A project can block transfers by overriding the transfer function, but then the only way for a marketplace or wallet to discover this is to simulate a transfer and watch it revert, which wastes gas and gives users a poor experience.

ERC-6454 adds the smallest possible signal: a single view function that says whether a given token can move, from whom, to whom.

How it works

function isTransferable(uint256 tokenId, address from, address to) external view returns (bool);

Rules:

  • If it returns false, the actual transfer must revert.
  • If tokenId does not exist it must revert, except when checking whether a token can be minted.
  • The from / to parameters let a contract express conditional rules (for example, "only transferable to whitelisted addresses").

Using the zero address as a convention:

Question from to
Is this token transferable in general? 0x0 0x0
Can it be minted? (non-existent tokenId allowed) 0x0 non-zero
Can it be burned? non-zero 0x0

General transferability does not cover minting and burning: a token that is non-transferable in general must still reject every ordinary transfer, but may be minted or burned.

There is deliberately no event and no function to change transferability. A token might become locked at a certain block or after some condition, where no transaction exists to emit an event, so the standard leaves state management to each implementation. Implementers may also use from to check approval, but callers should not rely on that.

The ERC-165 interface ID is 0x91a6262f.

Sample code

A badge that is mintable and burnable but otherwise bound to its owner:

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

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

interface IERC6454 {
    function isTransferable(uint256 tokenId, address from, address to) external view returns (bool);
}

contract Badge is ERC721, IERC6454 {
    constructor() ERC721("Badge", "BDG") {}

    function isTransferable(uint256 tokenId, address from, address to) public view returns (bool) {
        if (from == address(0) && to != address(0)) return true;   // mint check
        _requireOwned(tokenId);                                    // revert if missing
        return to == address(0) && from != address(0);              // only burning allowed
    }

    function _update(address to, uint256 tokenId, address auth) internal override returns (address) {
        address from = _ownerOf(tokenId);
        require(isTransferable(tokenId, from, to), "non-transferable");
        return super._update(to, tokenId, auth);
    }

    function supportsInterface(bytes4 id) public view override returns (bool) {
        return id == 0x91a6262f || super.supportsInterface(id);
    }
}

Things to know

  • Status is Final.
  • Transferability can change over time, so a dApp or marketplace should re-check it whenever it displays or lists a token rather than caching it.
  • A malicious contract can lie in isTransferable; the function is a hint, not a guarantee. Verify contracts you integrate with.
  • Related lock/soulbound standards take different approaches: ERC-5192 (locked plus events), ERC-6982 (gas-efficient default lock status) and ERC-7066 (lock with a designated unlocker).

#nft #soulbound #non-transferable #erc-165

Details

Authors
Bruno Škvorc (@Swader), Francesco Sullo (@sullof), Steven Pineda (@steven2308), Stevan Bogosavljevic (@stevyhacker), Jan Turk (@ThunderDeliverer)
Status
Final
Type
Standards Track / ERC
Created
2023-01-31
Requires

Machine-readable: Markdown · JSON