Script

Also: Bitcoin Script

cryptography · intermediate

Bitcoin's stack-based, non-Turing-complete programming language for expressing spending conditions on outputs.

Bitcoin Script is the small, stack-based language that defines who can spend an output. Each [transaction output](/glossary/output) carries a [locking script](/glossary/locking-script) (scriptPubKey) — a sequence of [opcodes](/glossary/opcode) that, when run with a candidate [unlocking script](/glossary/unlocking-script) (scriptSig or witness) pushed onto the stack first, must leave a non-zero value on top.

Design choices, all deliberate:

- Stack-based, no loops. Execution is bounded: the script can't loop forever and can't allocate unbounded memory. A node validating millions of transactions can give every script a constant-time worst case.
- No state between scripts. Each transaction's scripts run in isolation. There's no shared "contract" memory the way Ethereum has. Outputs are pure: same inputs always produce the same execution.
- Limited opcode set. Many opcodes were *removed* in early years (OP_CAT, OP_MUL, etc.) once Satoshi realized they enabled abuse. Newer features come back in disabled form via soft forks like Tapscript.

Scripts express common spending patterns: pay-to-public-key-hash, multisig, timelocks, hashlocks. With Tapscript (BIP-342, part of Taproot) and the eventual reintroduction of opcodes like OP_CAT, the language is slowly regaining expressiveness — but Script will never be Turing-complete. That's the feature.

Related terms

Where you'll see this