Bitcoin Script: The Programming Language Behind Every Transaction
Every Bitcoin transaction isn't just a value transfer — it's a script execution. Bitcoin Script is a simple, stack-based programming language that defines the conditions under which bitcoin can be spent. It's not Turing-complete (by design), but it's expressive enough to define complex spending conditions while remaining safe and predictable to execute on thousands of nodes simultaneously.
Stack-Based Execution
Bitcoin Script is a stack-based language — operations push data onto a stack or pop data off it to perform computations. A transaction is valid if, when the locking script (from the previous output) and the unlocking script (from the spending input) are executed together, the stack ends with a single TRUE value.
- scriptPubKey (locking script): Defines conditions to spend the output; set by the sender
- scriptSig (unlocking script): Provides data that satisfies the locking conditions; provided by the spender
- Witness (SegWit): Post-SegWit signature data stored separately from the transaction
Script Execution: Unlocking a UTXO
Why Not Turing-Complete?
Satoshi deliberately made Bitcoin Script not Turing-complete — it has no loops. This means every script terminates, execution time is bounded, and nodes can safely validate scripts without risk of infinite loops or resource exhaustion. Ethereum chose Turing-completeness (with gas limits to prevent infinite loops artificially) — a different trade-off with different security properties. Bitcoin's approach prioritises safety and predictability.
"Bitcoin Script is simple by design. It handles its use cases perfectly and nothing else. That limitation is its strength." — Bitcoin developer philosophy
Want to go deeper?
This content is written and approved by Marius, AI-assisted using Claude (Anthropic), with references curated from: Jameson Lopp (lopp.net, PD) · Mastering Bitcoin by A. Antonopoulos & D. Harding (CC BY-SA 4.0) · Blockchain Commons (CC BY 4.0) · Bitcoin Optech (bitcoinops.org, PD) · developer.bitcoin.org (MIT).