BA-06 · Advanced

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.

  1. Stack-machine execution

    Script is a deliberately constrained stack language whose success depends on final truth and consensus limits.

    Open lesson
  2. Pushes, arithmetic, and control flow

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

    Open lesson
  3. Signature checks and sighashes

    CHECKSIG validates a signature over a transaction digest selected by a sighash mode.

    Open lesson
  4. P2PKH and P2SH

    Legacy templates separate address-friendly commitments from revealed spending scripts.

    Open lesson
  5. Witness programs

    SegWit moves authorization data into witness structures and versions the program semantics.

    Open lesson
  6. Multisig and policy composition

    Multiple keys, timelocks, and hashlocks can form recovery, escrow, and channel policies.

    Open lesson
  7. Script limits and malleability

    Disabled opcodes, resource limits, encoding rules, and malleability protections constrain safe composition.

    Open lesson
  8. Script debugging

    Experts trace every stack transition, identify the failing predicate, and distinguish malformed witnesses from false conditions.

    Open lesson
  9. P2PK, 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 lesson
  10. Native and nested SegWit scripts

    Construct P2WPKH, P2WSH, P2SH-P2WPKH, and P2SH-P2WSH outputs and follow each redeem, witness, hash, and signature check.

    Open lesson