The Difference Between OP_0 and OP_FALSE
12. The Difference Between OP_0 and OP_FALSE
Overview
OP_0 and OP_FALSE are two names for the same single opcode byte 0x00. At the bytecode level, they are absolutely identical — there is no difference whatsoever in what they encode or how the interpreter processes them. However, the distinction between the two names carries important semantic and contextual meaning for script authors and protocol readers.
Identity: They Are the Same Opcode
// From Bitcoin Core src/script/script.h
enum opcodetype {
OP_0 = 0x00,
OP_FALSE = OP_0, // Identical alias
// ...
};
Both OP_0 and OP_FALSE map to the byte value 0x00. When serialized into a script, they produce exactly the same bytes. When executed, they produce exactly the same result: pushing an empty byte array [] onto the stack.
OP_0 serialized: 0x00
OP_FALSE serialized: 0x00
-- they are byte-for-byte identical in every context --
Semantic Convention: When to Use Which Name
The choice of name communicates the author's intent:
Use OP_FALSE when the value is being used in a boolean context — specifically when you want to push a false value onto the stack for use in a conditional or comparison:
Script intending to push boolean false:
OP_FALSE OP_IF ... OP_ENDIF -- this branch is never taken
Multisig dummy element (pushing a "false" sentinel):
OP_FALSE <sig1> <sig2>
Use OP_0 when the value is being used in a numeric or version context — when the zero represents the integer 0 or a version number:
SegWit version 0 witness program:
OP_0 <20-byte-hash> -- the OP_0 here is "version 0", not "false"
Arithmetic context:
OP_0 OP_1 OP_ADD -- result is 1 (starting from integer zero)
The Overlapping Semantics
Because Script has no separate boolean type, the integer 0 and the boolean false are the same thing at the representation level. An empty byte array is simultaneously:
-
The integer 0 (in arithmetic context)
-
The boolean
false(in conditional context) -
The SegWit version marker 0 (in output script context)
All three statements are simultaneously true:
OP_0 pushes the integer 0 ✓
OP_0 pushes boolean false ✓
OP_0 pushes SegWit version 0 ✓ (when followed by a 20 or 32-byte push)
Documentation and Readability
The dual naming convention exists purely for documentation clarity. A well-written script should use OP_FALSE in conditional or boolean contexts and OP_0 in numeric or version contexts, so that a reader can immediately understand the script author's intent without needing to reason about the execution environment. This convention is followed throughout the Bitcoin Improvement Proposals and in Bitcoin Core's own test vectors.
Historical Note
In the very earliest versions of Bitcoin, the opcode was simply OP_0. The alias OP_FALSE was added later to make script semantics more self-documenting. Similarly, OP_1 gained the alias OP_TRUE for the same reason.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: