The Bitcoin Script language is the core component that drives Bitcoin transactions. It's a specialized language that sets the rules for how Bitcoin can be spent, ensuring secure and verifiable transfers. This article explains Bitcoin Script, its purpose, how it functions, and its limitations. We'll also explore its relationship with smart contracts, the Lightning Network, sidechains, and Ordinals.
For a basic understanding of Bitcoin, see What is Bitcoin? and a quick introduction to Bitcoin. Diver deeper and learn about how Bitcoin transactions work and discover Bitcoin's origin story-from an idea to a global financial revolution.
Bitcoin Script is a stack-based scripting language, similar to Forth, but it's not Turing-complete. This means it can't perform complex calculations like loops or conditional branching, unlike languages used for general-purpose programming. This design choice prioritizes security and prevents issues like infinite loops that could disrupt the Bitcoin network.
Learn more about smart contracts and Turing completeness.
Bitcoin Script uses a system where data is pushed onto and popped off a "stack" during execution. Here's a simplified explanation of a Bitcoin transaction using Script:
Transaction Creation: When sending Bitcoin, your wallet creates a transaction with inputs (the Bitcoin being spent) and outputs (the recipient's address and amount). Learn more about sending Bitcoin.
Locking Script (ScriptPubKey): Each output has a locking script, setting the conditions for spending those Bitcoin. This script is linked to the recipient's address.
Unlocking Script (ScriptSig): To spend the Bitcoin, the sender provides an unlocking script that fulfills the locking script's conditions. This script, created by the sender's wallet, includes their digital signature, proving ownership.
Script Execution: The Bitcoin network runs the unlocking script followed by the locking script. If the combined execution results in "true," the transaction is valid.
Transaction Confirmation: Valid transactions are added to a block and then to the blockchain, confirming the Bitcoin transfer. Learn more about confirmations.
Locking Script (ScriptPubKey): OP_DUP OP_HASH160 <Recipient's Public Key Hash> OP_EQUALVERIFY OP_CHECKSIG
This script requires a signature matching the recipient's public key hash.
Unlocking Script (ScriptSig): <Signature> <Sender's Public Key>
This provides the signature and public key to unlock the Bitcoin.
Together, these scripts verify the signature against the public key and hash, ensuring the spender is the rightful owner.
Bitcoin Script's limitations have spurred innovative solutions:
Lightning Network: A layer-2 solution using Script for payment channels. Learn more about the Lightning Network.
Sidechains: Separate blockchains linked to Bitcoin, using Script for interoperability. Learn more about sidechains.
Ordinals: Using Script to add data to satoshis. Learn more: Bitcoin Ordinals.
Smart Contracts: While limited, Bitcoin Script allows for basic smart contracts like multi-signature wallets. Learn more about smart contracts on Bitcoin.
Bitcoin Script is a fundamental part of Bitcoin transactions, ensuring security and verifiability. Its limitations have led to innovative solutions like sidechains and the Lightning Network. Understanding Bitcoin Script helps you grasp how Bitcoin transactions work and the network's security model.
Learn about Bitcoin wallets and how to create one. Understand how to buy, send and receive Bitcoin. Also, explore Bitcoin's price history and Bitcoin price predictions.
Discover the top platforms for buying, selling, and trading cryptocurrencies
Discover the top platforms for buying, selling, and trading cryptocurrencies
Get a straightforward introduction to Bitcoin and why it matters.
Read this article →Get a straightforward introduction to Bitcoin and why it matters.
Understand how the Bitcoin public blockchain tracks ownership over time. Get clarity on key terms like public & private keys, transaction inputs & outputs, confirmation times, and more.
Read this article →Understand how the Bitcoin public blockchain tracks ownership over time. Get clarity on key terms like public & private keys, transaction inputs & outputs, confirmation times, and more.
Sending bitcoin is as easy as choosing the amount to send and deciding where it goes. Read the article for more details.
Read this article →Sending bitcoin is as easy as choosing the amount to send and deciding where it goes. Read the article for more details.
To receive bitcoin, simply provide the sender with your Bitcoin address, which you can find in your Bitcoin wallet. Read this article for more details.
Read this article →To receive bitcoin, simply provide the sender with your Bitcoin address, which you can find in your Bitcoin wallet. Read this article for more details.
Find out about blockchain confirmations, why they are important, and more.
Read this article →Find out about blockchain confirmations, why they are important, and more.
Discover what bitcoin fees are, how fees are determined, and more.
Read this article →Discover what bitcoin fees are, how fees are determined, and more.
Stay ahead in crypto with our weekly newsletter delivering the insights that matter most
Weekly crypto news, curated for you
Actionable insights and educational tips
Updates on products fueling economic freedom
No spam. Unsubscribe anytime.
Over wallets created so far
Everything you need to buy, sell, trade, and invest your Bitcoin and cryptocurrency securely
© 2025 Saint Bitts LLC Bitcoin.com. All rights reserved