EIPs Explained

ERC-5791 · Draft · ERC · 2022-10-17

ERC-5791: Physical Backed Tokens

Ties an ERC-721 NFT to a secure chip in a physical item, so only someone holding the item can get the chip to sign a transfer of the token.

What problem does it solve?

NFTs that represent sneakers, art or collectibles usually have two problems: owning the NFT and owning the object are separate things, and proving the object is authentic relies on a trusted third party.

Physical Backed Tokens (PBT) bind the two. A chip embedded in the item holds a private key that cannot be extracted. Whoever physically has the item can make the chip sign a message, and that signature is what moves the NFT. No central authority is needed to verify authenticity.

How it works

  • Each token is paired with a chip address derived from the chip's public key. Pairing emits ChipSet(tokenId, chipId) so indexers can map chips to tokens. A token cannot be minted without being linked to a chip.
  • The collection is account-bound: all normal ERC-721 transfer functions must revert. The only way to move a token is transferToken.
  • transferToken(to, chipId, chipSignature, signatureTimestamp, useSafeTransferFrom, extras) checks an ERC-191 signature from the chip over the recipient, the chip address, a recent block timestamp and any extra data, then transfers the token to to.
  • tokenIdFor(chipId) and isChipSignatureForToken(tokenId, data, signature) let anyone check that a chip backs a token.
  • Contracts advertise support via ERC-165 interface id 0x4901df9f.

Minting and how token ids get mapped to chips (preset by the owner, signed by a trusted party, a registry, first-come-first-served) are left to the implementation. Signature verification goes through the chip address, so chips are not limited to secp256k1.

Sample code

The interface:

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

interface IERC5791 {
    event ChipSet(uint256 indexed tokenId, address indexed chipId);

    function tokenIdFor(address chipId) external view returns (uint256 tokenId);

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

    function transferToken(
        address to,
        address chipId,
        bytes calldata chipSignature,
        uint256 signatureTimestamp,
        bool useSafeTransferFrom,
        bytes calldata extras
    ) external returns (uint256 tokenId);
}

The reference implementation builds the digest the chip signs roughly like this:

if (signatureTimestamp > block.timestamp) revert SignatureTimestampInFuture();
if (signatureTimestamp + maxDurationWindow < block.timestamp) revert SignatureTimestampTooOld();
bytes32 hash = keccak256(abi.encode(
    address(this), block.chainid, chipNonce[chipId], to, signatureTimestamp, keccak256(extras)
));
bytes32 digest = ECDSA.toEthSignedMessageHash(hash); // ERC-191

Things to know

  • Status is Draft; the interface may still change.
  • Trust in "physical backing" is only as good as the chip. Whether chip addresses really belong to real chips, and whether the chip stays attached and undamaged, are explicitly out of scope.
  • Including the recipient and a recent timestamp in the signed data prevents replay and stops someone from pre-signing transfers before handing the item over. A non-deterministic nonce is recommended.
  • The item holder can send the NFT to someone else by giving them a chip signature; the spec treats this like lending, since the holder can reclaim the NFT at any time.

#nft #physical #rwa #signatures

Details

Authors
2pmflow (@2pmflow), locationtba (@locationtba), Cameron Robertson (@ccamrobertson), cygaar (@cygaar), Brian Weick (@bweick), vectorized (@vectorized), djdabs (@djdabs)
Status
Draft
Type
Standards Track / ERC
Created
2022-10-17
Requires

Machine-readable: Markdown · JSON