Opcodes · push · enabled
OP_0 (0x00)
Pushes an empty byte string, which the VM reads as the number 0 and as false.
Verified
- Stack in → out
- ∅ → 0
- Since
- Original Bitcoin script
- Cost
- Base instruction cost 100; pushes 0 bytes.
- Bitcoin status
- Same in Bitcoin (BTC)
- Also known as
- OP_FALSE
Example
OP_0 OP_IF <0x01> OP_ELSE <0x02> OP_ENDIF <0x02> OP_EQUAL | Step | Stack after (top on the right) | What happens |
|---|---|---|
OP_0 | 0x | Pushes an empty item: the number 0, and false. |
OP_IF | ∅ | Pops the false item and skips to OP_ELSE; <0x01> never runs. |
<0x02> | 0x02 | The OP_ELSE branch runs. |
OP_ENDIF | 0x02 | Closes the conditional. |
<0x02> | 0x02 0x02 | |
OP_EQUAL | 1 | The ELSE branch ran, so the script ends true. |
Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.
Where OP_0 is used
- Contracts CashScript function selector : A CashScript contract with several functions picks one by an index the spender pushes. Index 0 is an empty push, which minimal encoding writes as OP_0.
- Tutorial Token Pioneers Tutorial 4: parsable NFTs : Decodes NFT commitment bytecode that starts with OP_0 OP_TOALTSTACK.
- Upgrade November 2019: Schnorr multisig and MINIMALDATA : Made minimal pushes a consensus rule, so an empty or zero push must be OP_0.
- CHIP VM Limits: Targeted Virtual Machine Limits : Sets the base instruction cost of 100 that OP_0 pays.