Bitcoin Script
Execute locking conditions one opcode and stack item at a time.
Follow these 10 lessons in order, or choose the topic you need. Each lesson combines an explanation, a worked example and practice inside the Guild.
Stack-machine execution
Script is a deliberately constrained stack language whose success depends on final truth and consensus limits.
Open lessonPushes, arithmetic, and control flow
Data pushes, numeric encodings, conditionals, and verification opcodes compose spending policies.
Open lessonSignature checks and sighashes
CHECKSIG validates a signature over a transaction digest selected by a sighash mode.
Open lessonP2PKH and P2SH
Legacy templates separate address-friendly commitments from revealed spending scripts.
Open lessonWitness programs
SegWit moves authorization data into witness structures and versions the program semantics.
Open lessonMultisig and policy composition
Multiple keys, timelocks, and hashlocks can form recovery, escrow, and channel policies.
Open lessonScript limits and malleability
Disabled opcodes, resource limits, encoding rules, and malleability protections constrain safe composition.
Open lessonScript debugging
Experts trace every stack transition, identify the failing predicate, and distinguish malformed witnesses from false conditions.
Open lessonP2PK, P2PKH, P2MS, P2SH, and OP_RETURN
Compare the exact assembly, serialized bytes, spend data, standard uses, and failure boundary for Bitcoin's classic Script templates.
Open lessonNative and nested SegWit scripts
Construct P2WPKH, P2WSH, P2SH-P2WPKH, and P2SH-P2WSH outputs and follow each redeem, witness, hash, and signature check.
Open lesson