EIPs Explained

ERC-5192 · Final · ERC · 2022-07-01

ERC-5192: Minimal Soulbound NFTs

The smallest possible soulbound-token standard: an ERC-721 extension with a `locked(tokenId)` flag so wallets and marketplaces can detect that a token cannot be transferred.

What problem does it solve?

Some tokens should never change hands: credentials, attendance badges, achievements, memberships, reputation. These "soulbound" tokens (named after non-tradeable items in World of Warcraft) were being built as normal ERC-721 contracts that simply revert on transfer.

That works on-chain, but a wallet or marketplace has no way to know in advance. It shows a "Transfer" or "List for sale" button, the user tries, and the transaction fails. Each project also signalled non-transferability differently.

ERC-5192 adds a minimal, detectable flag so tools can recognise soulbound tokens up front.

How it works

The interface has one function and two events:

interface IERC5192 {
    event Locked(uint256 tokenId);
    event Unlocked(uint256 tokenId);
    function locked(uint256 tokenId) external view returns (bool);
}
  • If locked(tokenId) returns true, every ERC-721 function that would transfer that token must revert.
  • Locked / Unlocked are emitted when the status changes, and at mint to announce the initial status.
  • Querying a token owned by the zero address (i.e. one that does not exist) must revert.
  • The contract must return true from supportsInterface(0xb45a3c0e) (ERC-165).

Because locking is per token, a contract can mix transferable and non-transferable tokens, or unlock a token later.

Sample code

A simple soulbound badge using OpenZeppelin v5:

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

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface IERC5192 {
    event Locked(uint256 tokenId);
    event Unlocked(uint256 tokenId);
    function locked(uint256 tokenId) external view returns (bool);
}

contract Badge is ERC721, Ownable, IERC5192 {
    constructor() ERC721("Badge", "BDG") Ownable(msg.sender) {}

    function mint(address to, uint256 tokenId) external onlyOwner {
        _safeMint(to, tokenId);
        emit Locked(tokenId);
    }

    function locked(uint256 tokenId) external view returns (bool) {
        _requireOwned(tokenId); // reverts for nonexistent tokens
        return true;
    }

    // Allow mint (from == 0) and burn (to == 0); block everything else.
    function _update(address to, uint256 tokenId, address auth) internal override returns (address) {
        address from = _ownerOf(tokenId);
        require(from == address(0) || to == address(0), "soulbound");
        return super._update(to, tokenId, auth);
    }

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

Checking from a frontend (ethers v6):

const isSBT = await nft.supportsInterface("0xb45a3c0e");
const isLocked = isSBT && (await nft.locked(tokenId));

Things to know

  • Status: Final.
  • "Locked" means transfers revert. It does not say whether the holder can burn the token, or who can unlock it; those are up to each contract.
  • The standard only requires transfer functions to revert; it says nothing about approve, which is harmless but useless for a locked token.
  • Related approaches add more structure: ERC-5484 (consensual soulbound tokens with burn authorisation), ERC-4973 (account-bound tokens) and ERC-5114 (soulbound badges bound to another NFT).

#nft #soulbound #erc721 #identity

Details

Authors
Tim Daubenschütz (@TimDaub), Anders (@0xanders)
Status
Final
Type
Standards Track / ERC
Created
2022-07-01
Requires
Required by

Machine-readable: Markdown · JSON