Opcodes · control · enabled
OP_IF (0x63)
Pops the top item; if it is true, runs the statements that follow up to OP_ELSE or OP_ENDIF. Any value works as the condition. BCH does not require it to be minimally encoded.
Verified
- Stack in → out
- cond → ∅
- Since
- Original Bitcoin script
- Cost
- Base instruction cost 100. Control stack depth is limited to 100 (2025 VM limits).
- Bitcoin status
- Behaves differently in Bitcoin (BTC)Tapscript (BIP-342) requires the condition to be exactly empty or 0x01, and BTC relay policy asks the same of SegWit v0 scripts. BCH has no such rule.
Example
OP_IF <pubkeyA> OP_ELSE <pubkeyB> OP_ENDIF OP_CHECKSIG Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.