← Starting Henceforth

Episode 10

Bitcoin script

Everything you've typed since episode two was bitcoin all along — watch a real lock assemble, byte by byte.

1:26 · Brandenburg No. 3 · Allegro (BWV 1048 i)

Watch here · code in the app

Henceforth is the real terminal — one purchase ($9.99) for iPhone, iPad and Mac. Type the commands below into the app as you watch.

Code along

Tap to copy, then type it into Henceforth.

What you’ll learn

  • Bitcoin Script is FORTH's family — stack-based, postfix, made of words. Every bitcoin transaction carries a small script, and you've been writing its style since episode two.
  • script-begin flips the terminal into recording: every word now writes bytes instead of executing. op_dup op_hash160, twenty bytes of hash, op_equalverify op_checksig — the pay-to-public-key-hash lock assembles live.
  • script-end hands back twenty-five bytes — the exact lock that guards coins on nearly every bitcoin address. The hash on screen is the genesis coinbase address's hash160.
Transcript
  • and now... bitcoin?
  • bitcoin is FORTH too!
  • stack-based. postfix. words.
  • every transaction carries a small script.
  • you already know it.
  • you've been writing it since episode two.
  • pay-to-public-key-hash:
  • OP_DUP OP_HASH160 <hash> OP_EQUALVERIFY OP_CHECKSIG
  • that's the lock on nearly every address.
  • want to see one built?
  • recording. every word now writes bytes.
  • duplicate the key. hash it.
  • twenty bytes. satoshi's address — block zero.
  • match the hash. check the signature.
  • twenty-five bytes. FORTH wrote a real bitcoin lock.
  • that exact hex guards coins on every wallet on earth.
  • every transaction. just FORTH.
  • henceforth.