Opcodes · token · enabled

OP_OUTPUTTOKENCATEGORY (0xd1)

Pushes the token category of output i, with a capability byte appended for mutable (0x01) or minting (0x02) NFTs. Pushes 0 if the output holds no tokens.

Verified
Stack in → out
i → category[+cap] | 0
Cost
Base instruction cost 100 plus the byte length of the pushed result (2025 VM limits).
Bitcoin status
Not in Bitcoin (BTC)BTC has no native tokens. In Tapscript (BIP-342) this byte is an OP_SUCCESSx code reserved for future soft forks.

Example

OP_0 OP_OUTPUTTOKENCATEGORY OP_INPUTINDEX OP_UTXOTOKENCATEGORY OP_EQUAL
Step Stack after (top on the right) What happens
OP_0 0
OP_OUTPUTTOKENCATEGORY cat Output 0's 32-byte category, plus 0x01 or 0x02 if it holds a mutable or minting NFT.
OP_INPUTINDEX cat 0 This input's index, here 0.
OP_UTXOTOKENCATEGORY cat cat The category of the token this input spends.
OP_EQUAL 1 Output 0 carries the same category and capability as the token this input spends. A covenant also checks OP_OUTPUTBYTECODE to pin where it goes.

Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.

Where OP_OUTPUTTOKENCATEGORY is used

Sources

  1. CHIP-2022-02 CashTokens: Token Primitives for Bitcoin Cash
  2. Libauth BCH_2023_05 opcodes (bch-2023-opcodes.ts)