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
- CHIP CashTokens: Token Primitives for Bitcoin Cash : Defines OP_OUTPUTTOKENCATEGORY with the other token introspection opcodes.
- Upgrade May 2023: CashTokens, P2SH32 and smaller transactions : Activated CashTokens on mainnet.
- Contracts CashScript tx.outputs[i].tokenCategory : Compiles to OP_OUTPUTTOKENCATEGORY. The CashScript docs warn the bytes come in unreversed order.
- Tutorial Token Pioneers Tutorial 2: mint your first NFTs : Mints the NFTs whose category and capability this opcode reads.