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-5791 proposes a minimal interface for linking NFT ownership to physical cryptographic chips.

This article explains the proposal, with additional context and examples.

This article describes the proposal as discussed in September 2023. The original notice referred to ERC-5008, apparently in error; this article concerns ERC-5791. The citation records the historical draft.

Overview

The standard builds on ERC-721, which defines an interface for non-fungible tokens representing distinct digital assets and ownership records.

The proposed extension enables physically backed tokens by associating an NFT with a real-world object, such as a painting or collectible. The goal is to give someone with access to the object's cryptographic chip a way to obtain ownership of its associated NFT.

This provides a direct technical connection between a physical item's holder and the NFT's recorded owner. For example, someone receiving a painting with its registered chip can use a valid chip signature to transfer the corresponding NFT to their own wallet.

The relationship is not automatically synchronized merely by physically handing over the item, and holding an NFT does not by itself establish legal title to the object. These depend on the transfer process, chip attachment, and applicable legal arrangements.

The proposal creates new possibilities for connecting digital collectibles with physical assets and their provenance.

Motivation

NFT collectors can display and share digital assets online. Physical collectibles, however, lack a common mechanism for showing an online ownership record that is reliably associated with possession of the underlying item.

Existing approaches may have two limitations.

  1. The physical item's holder and its associated NFT owner may differ.
  2. Authenticating the physical item may require intervention by a trusted intermediary such as StockX.

ERC-5791 aims to provide a consistent interface for linking physical possession to an on-chain ownership record while reducing reliance on intermediaries for subsequent token transfers. Initial authentication of the physical asset remains a separate concern.

Specification

Requirements

The physical item must have a chip that meets the following requirements.

  1. It can securely generate and store an asymmetric ECDSA key pair on the secp256k1 curve.
  2. It can sign messages using the generated private key.
  3. It can expose its public key.
  4. Its private key cannot be extracted externally under the assumed chip security model.

The approach uses an account-bound implementation of ERC-721. Ordinary ERC-721 transfer operations revert, while ownership updates take place through the additional chip-authorized interface.

This resembles a read-only NFT registry from the perspective of standard ERC-721 transfer methods.

Read-only NFT registry

This pattern customizes ERC-721 to manage NFTs under specific transfer restrictions.

  1. Read-only standard transfer behavior: ordinary owner-initiated transfers revert instead of allowing unrestricted NFT movement.
  2. Physical asset association: chip-authorized transfers provide a mechanism for tying control of the NFT to access to the physical item.
  3. Reduced intermediary involvement: a chip signature can be verified without requiring an appraiser or certification organization to approve every subsequent transfer.

This approach can help collectors maintain and display digital records associated with physical items. It does not independently authenticate the underlying object or guarantee that the chip cannot be removed, copied, or misused.

As a result, obtaining a valid chip signature becomes part of the NFT's ownership-update process. The proposed interface defines the additional operations used for that purpose.

Approach

Each NFT is associated with a physical chip.

When an NFT is minted, an event includes the chip address, a 20-byte Ethereum-style address derived from the chip's public key. Indexing systems can use the event to determine which chip corresponds to a particular token in the collection.

Minting requires a corresponding chip association.

The interface also defines transferTokenWithChip, which transfers the associated NFT to the caller when a valid chip signature is provided. The signature must follow the relevant EIP-191 and EIP-2 requirements.

The signed data includes the recipient address, which must correspond to the message sender, and a recent block hash. Implementations may define their own acceptable block-hash freshness window.

The interface also allows anyone to check whether a chip embedded in an item corresponds to a token in the collection.

This makes chip-to-token associations verifiable, subject to the security of the chip and the integrity of the initial registration.

Interface

javascript
interface IERC5791 {
    /// @notice Returns the token id for a given chip address.
    /// @dev Throws if there is no existing token for the chip in the collection.
    /// @param chipAddress The address for the chip embedded in the physical item (computed from the chip's public key).
    /// @return The token id for the passed in chip address.
    function tokenIdFor(address chipAddress) external view returns (uint256);

    /// @notice Returns true if the chip for the specified token id is the signer of the signature of the payload.
    /// @dev Throws if tokenId does not exist in the collection.
    /// @param tokenId The token id.
    /// @param payload Arbitrary data that is signed by the chip to produce the signature param.
    /// @param signature Chip's signature of the passed-in payload.
    /// @return Whether the signature of the payload was signed by the chip linked to the token id.
    function isChipSignatureForToken(uint256 tokenId, bytes calldata payload, bytes calldata signature)
        external
        view
        returns (bool);

    /// @notice Transfers the token into the message sender's wallet.
    /// @param signatureFromChip An EIP-191 signature of (msgSender, blockhash), where blockhash is the block hash for blockNumberUsedInSig.
    /// @param blockNumberUsedInSig The block number linked to the blockhash signed in signatureFromChip. Should be a recent block number.
    /// @param useSafeTransferFrom Whether EIP-721's safeTransferFrom should be used in the implementation, instead of transferFrom.
    ///
    /// @dev The implementation should check that block number be reasonably recent to avoid replay attacks of stale signatures.
    /// The implementation should also verify that the address signed in the signature matches msgSender.
    /// If the address recovered from the signature matches a chip address that's bound to an existing token, the token should be transferred to msgSender.
    /// If there is no existing token linked to the chip, the function should error.
    function transferTokenWithChip(
        bytes calldata signatureFromChip,
        uint256 blockNumberUsedInSig,
        bool useSafeTransferFrom
    ) external;

    /// @notice Calls transferTokenWithChip as defined above, with useSafeTransferFrom set to false.
    function transferTokenWithChip(bytes calldata signatureFromChip, uint256 blockNumberUsedInSig) external;

    /// @notice Emitted when a token is minted
    event PBTMint(uint256 indexed tokenId, address indexed chipAddress);

    /// @notice Emitted when a token is mapped to a different chip.
    /// Chip replacements may be useful in certain scenarios (e.g. chip defect).
    event PBTChipRemapping(uint256 indexed tokenId, address indexed oldChipAddress, address indexed newChipAddress);
}

A conforming contract must return true when ERC-165's supportsInterface(bytes4 interfaceID) is called with interface ID 0x4901df9f.

Minting behavior may differ between implementations, but the token's initial ownership should correspond to the physical chip holder. The signature scheme used by transferTokenWithChip can support this check.

The interface also declares PBTMint for recording a new token-to-chip association and PBTChipRemapping for recording a replacement chip, for example when the original chip is defective.

The following sections describe the interface functions.


tokenIdFor

javascript
function tokenIdFor(address chipAddress) external view returns (uint256);

Overview

Returns the token ID associated with a specified chip address.

Details

The function looks up the chip-to-token association and reverts if no corresponding token exists in the collection.

Parameters

  • chipAddress
    • The address derived from the public key of the chip embedded in the physical item.

Return value

  • uint256
    • The token ID associated with the chip address.

isChipSignatureForToken

javascript
function isChipSignatureForToken(uint256 tokenId, bytes calldata payload, bytes calldata signature)
    external
    view
    returns (bool);

Overview

Checks whether the chip associated with a specified token signed a supplied payload.

Details

The function verifies the supplied signature against the chip registered for the token. It reverts if the token does not exist in the collection.

Parameters

  • tokenId
    • The token ID.
  • payload
    • Arbitrary data signed by the chip.
  • signature
    • The chip's signature.

Return value

  • bool
    • True if the registered chip signed the payload; otherwise false.

transferTokenWithChip

javascript
function transferTokenWithChip(bytes calldata signatureFromChip, uint256 blockNumberUsedInSig, bool useSafeTransferFrom)
    external;

Overview

Transfers the token associated with a chip to the message sender using the chip's signature.

Details

The implementation checks that the block number used in the signature is sufficiently recent and that the signed recipient address matches the message sender. It recovers the signing chip address and identifies the associated token.

If the recovered chip address is bound to an existing token, that token is transferred to the caller. The function reverts if no such token exists.

Parameters

  • signatureFromChip
    • An EIP-191 signature over the message sender and block hash.
  • blockNumberUsedInSig
    • The block number corresponding to the signed block hash.
  • useSafeTransferFrom
    • Whether the implementation uses ERC-721 safe transfer behavior instead of ordinary transfer behavior.

transferTokenWithChip

javascript
function transferTokenWithChip(bytes calldata signatureFromChip, uint256 blockNumberUsedInSig) external;

Overview

An overload that performs the same operation with useSafeTransferFrom set to false.

Parameters

  • signatureFromChip
    • The chip's EIP-191 signature.
  • blockNumberUsedInSig
    • The block number used to obtain the signed block hash.

Rationale

The proposal aims to provide a simple mechanism for associating physical items with digital NFTs without requiring a centralized intermediary to approve each transfer.

The transferTokenWithChip function defines a common chip signature scheme so other NFT implementations adopting the proposal can support compatible chip-authorized ownership transfers.

Out of scope

The proposal does not address several physical security and registration problems:

  • Establishing that a registered chip address actually corresponds to the chip embedded in the genuine item.
  • Ensuring chips do not deteriorate or become damaged.
  • Ensuring the chip is securely attached to the physical item.

These issues require separate solutions.

The procedure for initially mapping token IDs to chip addresses is also outside the proposal's scope. Possible approaches include preconfiguring associations through the contract owner, supplying a signed token ID and chip address tuple during Mint, looking up mappings in a trusted registry, or assigning IDs on a first-come, first-served basis during Mint.

A physical item holder may provide a chip signature for another person's wallet so that person can obtain the NFT without receiving the physical item.

The token can still be considered physically backed in the proposal's sense because the holder participated in authorizing the transfer and can potentially reclaim the NFT using a fresh chip signature, provided they retain access to the functioning chip and the implementation permits the transfer.

Backward compatibility

The proposal retains ERC-721 API compatibility. To enforce physical backing, ordinary ERC-721 transfers are disabled by reverting, and ownership changes instead use the added chip-signature functions.

Applications must therefore account for these transfer restrictions. Existing marketplaces that assume unrestricted ERC-721 transfers may need additional integration.

Reference implementation

javascript
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';

function getChipAddressFromChipSignature(
  bytes calldata signatureFromChip,
  uint256 blockNumberUsedInSig
) internal returns (TokenData memory) {
  if (block.number <= blockNumberUsedInSig) {
    revert InvalidBlockNumber();
  }
  unchecked {
    if (block.number - blockNumberUsedInSig > getMaxBlockhashValidWindow()) {
      revert BlockNumberTooOld();
    }
  }
  bytes32 blockHash = blockhash(blockNumberUsedInSig);
  bytes32 signedHash = keccak256(abi.encodePacked(_msgSender(), blockHash))
    .toEthSignedMessageHash();
  address chipAddr = signedHash.recover(signatureFromChip);
}

getChipAddressFromChipSignature

Overview

Recovers the chip address from a chip signature.

Details

The example compares the current block number with the signed block number to ensure that the referenced block is recent and is not the current or a future block.

It obtains the referenced block hash, combines it with the message sender, constructs an EIP-191 signed-message hash, and recovers the chip address.

The original code fragment is reproduced unchanged. It is not a complete compilable function: the declared return type is TokenData, while the body recovers an address and omits a return statement. The following description explains its intended output rather than asserting the snippet works as written.

Parameters

  • signatureFromChip
    • The chip's signature.
  • blockNumberUsedInSig
    • The block number corresponding to the signed hash.

Intended result

  • chipAddr
    • The recovered chip address.

Security considerations

The EIP-191 signature passed to transferTokenWithChip binds the signature to the caller's address. This limits the ability of another address to reuse the signature to claim the token.

Including a recent block hash restricts the time during which a precomputed signature remains valid, reducing the risk that a previous physical holder can reuse old signatures after handing over the item.

These measures do not provide universal replay protection. Implementations must consider repeated use within the validity window, block-hash availability, and whether signatures can be reused across chains or collections.

The physical backing ultimately depends on the chip's security, resistance to private-key extraction, and trustworthy association with the real-world item. Those physical security guarantees are outside the scope of the standard.

Citation

2pmflow (@2pmflow), locationtba (@locationtba), Cameron Robertson (@ccamrobertson), cygaar (@cygaar), Brian Weick (@bweick), "ERC-5791: Physical Backed Tokens [DRAFT]," Ethereum Improvement Proposals, no. 5791, October 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5791.

Conclusion

ERC-5791 proposes a minimal interface for linking NFT ownership to cryptographic chips embedded in physical objects. Its signature-based ownership transfer mechanism offers a way to associate on-chain ownership with control of a physical chip.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777