Reviewed Aug 2026
DE
BA-06 · LESSON 02

Pushes, arithmetic, and control flow

KEY DEFINITIONS

Terms used in this lesson

OP_IF
A Bitcoin Script conditional operation that executes one branch when the consumed condition is true.
OP_VERIFY
A Bitcoin Script operation that consumes a value and immediately fails if it is false.
Witness
Signatures, scripts, or other data supplied to satisfy a Bitcoin output’s spending condition.
OP_ELSE
The marker for the alternate branch of a Bitcoin Script conditional.
OP_ENDIF
The marker that ends a Bitcoin Script conditional block.
OP_SUB
A Bitcoin Script operation that removes two script numbers and pushes the first minus the second.
OP_EQUALVERIFY
A Bitcoin Script operation that compares two values and immediately fails if they differ.
OP_EQUAL
A Bitcoin Script operation that compares two byte strings and pushes true or false.
UTXO
Unspent transaction output: one discrete chunk of bitcoin that can be used as a transaction input.

Data pushes, numeric encodings, conditionals, and verification opcodes compose spending policies.

45 min Difficulty 2/5 Not started

Loading lesson visuals...

01

Learn the idea

Script data pushes place byte strings on the stack. Script numbers use a signed-magnitude little-endian byte encoding with minimal-encoding rules in relevant contexts. Conditional opcodes OP_IF, OP_ELSE, and OP_ENDIF choose which branch executes based on a stack boolean, while skipped branches are parsed but most contained operations are not executed.

GUIDED EXPLANATION1/5 ideas inspected
1

Push minimally encoded numbers

Small integer opcodes directly push values from negative one through sixteen. Larger script numbers are byte vectors whose sign uses the high bit of the final byte.

Inspect each idea before the worked example.
The worked example follows the explanation

Inspect every idea above to open it.

Important distinctionOP_IF reads a permanent variable stored in the UTXO.

It consumes a stack item supplied or computed during this spend. Script has no mutable variable store attached to an output.

02
FINISH LEARNING FIRST

The questions unlock after every required learning activity

Inspect every guided idea, open the worked example, rebuild its mechanism, and complete the deterministic lesson tool. Your progress is saved automatically.