Source: docs/lotus-v2/examples/evm-porting/erc721.md

ERC721: unique assets and approvals

Original behavior

ERC721 identifies an NFT by contract address plus uint256 token ID. It tracks owner, individual approval and operator approval; safe transfer calls a contract recipient's receiver hook. OpenZeppelin clears token approval as ownership changes. ERC721, OpenZeppelin ERC721 v5.0.2.

UTXO representation

Use one Lotus asset ID per NFT, issued exactly once with amount 1. The collection is an authenticated manifest or collection-controller namespace mapping its original uint256 IDs to Lotus TokenIds. Mint identity must commit to a unique consumed seed or a uniquely consumed collection-controller transition; delta == 1 alone permits repeated issuance. The NFT's holder coin carries owner/approval state and mandatory collection rules if revocation/royalties are intended. The holder coin is the unique live owner record, not merely a coin whose root resembles the collection template.

Collection-wide operators require an owner authority coin or authenticated approval map consumed by each use. This makes ownership/operators explicit and serialized where shared. Immutable independently signed operator certificates cannot implement revocation by themselves. A token-level approval lives in the NFT state and is cleared on transfer. The holding code reads its asset from the consumed coin instead of embedding its own future mint root; the one-time mint can then commit to that holding code without a root cycle. The collection namespace is independently established, not a recursively defined root of every NFT program.

Proposed Lotus sample

This is LC-1 semantic source, not compiled. unique_input, output policies and codecs are proposed library operations with the obligations below.

contract UniqueHolding<collection: Bytes32> {
    state separate { owner: PublicKey, approved: PublicKey, hasApproval: Bool }
    entry approve(delegate: PublicKey, sig: Signature) transition {
        nft = this.coin.token_id;
        require(unique_input(this, nft, 1));
        require(checksig(sig, owner));
        next = {owner: owner, approved: delegate, hasApproval: true};
        successor holding at outputs[this.input_index]
            preserves this.policy with state = next;
    }
    entry transfer(to: PublicKey, sig: Signature) transition {
        nft = this.coin.token_id;
        require(unique_input(this, nft, 1));
        require(checksig(sig, owner) ||
                (hasApproval && checksig(sig, approved)));
        next = {owner: to, approved: zero_key_encoding, hasApproval: false};
        successor holding at outputs[this.input_index]
            asset = nft, value = 1, policy = holding_policy(next);
    }
    entry burn(sig: Signature) terminal {
        nft = this.coin.token_id;
        require(unique_input(this, nft, 1) && checksig(sig, owner));
        require(total_output_value(nft) == 0);
    }
}

zero_key_encoding is inert encoded state guarded by hasApproval; it must not be passed to a key parser/checksig. A tagged optional key is preferable in the actual codec. Short-circuit behavior must preserve that guard. unique_input checks exact asset, amount and authenticated state, and rejects another input/output carrying a positive quantity in the same transition where that would violate the contract. Genesis single issuance and native asset conservation provide global uniqueness. Approve recreates value 1 and exact policy/state; transfer recreates exactly one such output, preserves mandatory collection restrictions, and clears approval. Burn leaves no spendable copy and cannot enable a second seed mint. Constructor initialization is enforced by the issuance program.

A safe-receive variant requires recipient authorization over the planned output policy, via an additional consumed consent coin or explicit data signature. This is consent to a transaction, not an onERC721Received callback. A plain transferred output does not execute its recipient program at creation. A receiver cannot reject an unsolicited deposit unless the sending covenant requires that consent. The proposed API therefore names these separately: transfer versus transferWithConsent.

Invariants, attacks and work

Require one-time seed consumption, no positive NFT delta after issuance, at most one spendable amount-1 holding, correct owner signature or live approval, and approval reset after transfer. Test mint twice with two fee coins, counterfeit policy roots, zero-valued counterfeit NFTs, forged collection metadata, old-owner/old-approval reuse, wrong recipient policy, unauthorized operator revocation, simultaneous approve/transfer conflict, and burn/remint. Test recipient-consent replay against another NFT, chain or policy.

No full NFT is executed here. Threshold/escrow signatures validate only underlying authorization primitives. The lifecycle requires frontend state/roles, library unique issuance and optional-key/map codecs, SDK exact consent bytes and collection resolution, and indexer collection/token/owner lookup with reorg handling. VM/transaction: existing asset and covenant operations appear sufficient for this explicit lifecycle; prove with bytecode before making that a coverage claim. Consensus: no new opcode is proposed. An exact ERC721 safe callback is outside the invocation model and must not be advertised as implemented.


References

  1. [Entriken, Shirley, Evans, & Sachs 2018] William Entriken, Dieter Shirley, Jacob Evans, and Nastassia Sachs, "EIP-721: Non-Fungible Token Standard", Ethereum Improvement Proposals, January 2018.
  2. [O'Connor & Piekarska 2017] Russell O'Connor and Marta Piekarska, "Enhancing Bitcoin Transactions with Covenants", in Financial Cryptography and Data Security (FC 2017), LNCS vol. 10323, pp. 191–198, 2017.
  3. [Wuille, Nick, & Ruffing 2020] Pieter Wuille, Jonas Nick, and Tim Ruffing, "BIP 340: Schnorr Signatures for secp256k1", Bitcoin Improvement Proposals, January 2020.