TeachMeBitcoin

OP_0 (OP_FALSE) - Pushing Zero

From TeachMeBitcoin, the free encyclopedia Reading time: 4 min

1. OP_0 (OP_FALSE) — Pushing Zero

Overview

OP_0, also known as OP_FALSE, is one of the most foundational and frequently used opcodes in Bitcoin Script. It occupies opcode byte 0x00 and its sole purpose is to push an empty byte array onto the stack. Though this may sound trivial, the semantic implications of OP_0 permeate nearly every aspect of Bitcoin's scripting system — from multisignature transactions to SegWit witness programs.

Opcode Value and Encoding

In raw Bitcoin Script, OP_0 is encoded as a single byte:

0x00

When the Script interpreter encounters this byte, it does not read any additional bytes. Instead, it pushes an empty byte array [] onto the stack immediately. This makes OP_0 the most compact possible push operation in the entire opcode space.

What "Zero" Means in Script

Bitcoin Script does not have a native integer type in the way conventional programming languages do. Numbers are represented as byte arrays using a sign-magnitude encoding (sometimes called "Script number" encoding). Under this convention, the number zero is represented by an empty byte array — not by the byte 0x00, but by an array of length zero: [].

This is a critical distinction. If you push 0x00 as data, that is actually the number zero represented as a one-byte array with the byte value zero, which Script considers a zero-length canonical representation. OP_0 pushes truly nothing — an empty array — and this empty array evaluates to false in any boolean context.

Stack before: [ ... ]
OP_0 executes
Stack after:  [ ... | <empty> ]

Boolean Semantics

Bitcoin Script treats stack items as booleans in conditional contexts. An item evaluates to false if it is:

Everything else evaluates to true. Since OP_0 pushes an empty array, it is by definition a false value. This is why OP_0 and OP_FALSE are used interchangeably — they refer to the exact same opcode pushing the exact same value.

Pseudocode evaluation:
item = []           --> false (OP_0 / OP_FALSE)
item = [0x00]       --> false (also zero, different encoding)
item = [0x01]       --> true
item = [0xFF, 0x00] --> true (positive 255)

Critical Role in Multisig

One of the most important uses of OP_0 appears in standard Pay-to-MultiSig (P2MS) scripts and their P2SH equivalents. Bitcoin Core's original implementation of OP_CHECKMULTISIG contains a well-known off-by-one bug: it consumes one extra item from the stack beyond what it should. To compensate, every multisig scriptSig must begin with an OP_0 as a dummy value.

Multisig scriptSig (2-of-3 example):
OP_0 <sig1> <sig2>

Without the leading OP_0, OP_CHECKMULTISIG would consume the last real signature as the dummy, causing the script to fail. This quirk has been preserved across Bitcoin's entire history because changing it would require a hard fork. BIP 147 ("Dealing with dummy element of CHECKMULTISIG and CHECKMULTISIGVERIFY") later enforced that this dummy element must be exactly OP_0 — not arbitrary data — as a soft fork.

Locking script (2-of-3 P2MS):
OP_2 <pubkey1> <pubkey2> <pubkey3> OP_3 OP_CHECKMULTISIG

Unlocking script:
OP_0 <sig1> <sig2>

SegWit Version Marker

OP_0 also plays a pivotal role in SegWit (Segregated Witness) output encoding. Native SegWit outputs begin their scriptPubKey with OP_0 followed by a data push of either 20 bytes (P2WPKH) or 32 bytes (P2WSH). The OP_0 byte signals to the interpreter that this is a version-0 witness program.

P2WPKH scriptPubKey:
OP_0 <20-byte-hash>
Hex: 0x00 0x14 <20 bytes>

P2WSH scriptPubKey:
OP_0 <32-byte-hash>
Hex: 0x00 0x20 <32 bytes>

Taproot (P2TR) uses OP_1 (discussed in the next section) as its version marker, not OP_0. This distinction enables nodes to distinguish witness program versions at a glance.

Source Code Reference

In Bitcoin Core, OP_0 is defined in script/script.h:

// From Bitcoin Core src/script/script.h
enum opcodetype {
    // push value
    OP_0 = 0x00,
    OP_FALSE = OP_0,
    // ...
};

The execution logic in script/interpreter.cpp handles OP_0 by pushing an empty vector:

case OP_0: {
    // Push empty vector onto stack
    stacktop.push_back(valtype());
    break;
}

Summary

OP_0 / OP_FALSE is a single-byte opcode (0x00) that pushes an empty byte array onto the stack. It represents the boolean value false and the integer 0 in Script arithmetic. Its uses span from multisig dummy values to SegWit version markers, making it indispensable despite its simplicity.


☕ Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!