Explore All Reviews

What is the Bitcoin Script Language?

The Bitcoin Script language is a simple, stack-based scripting language used to define the spending conditions of Bitcoin transactions. It prioritizes security and minimizes complexity, playing a crucial role in Bitcoin's functionality.
What is the Bitcoin Script Language?
Manage your Bitcoin securely with the self-custody Bitcoin.com Wallet app.

Decoding Bitcoin Script: The Language of Bitcoin Transactions

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.

What is Bitcoin Script?

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.

How Bitcoin Script Works

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. Transaction Confirmation: Valid transactions are added to a block and then to the blockchain, confirming the Bitcoin transfer. Learn more about confirmations.

Example: A Simple Bitcoin Transaction in Script

  • 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:

Conclusion

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


🟠 Bitcoin Ecosystem Resources

Bitcoin Exchange & Trading Platforms

Bitcoin Wallets & Storage

Bitcoin Data, Tools & Charts

Bitcoin ATMs & Physical Infrastructure

Bitcoin Investment & Finance

Bitcoin Commerce & Lifestyle

Bitcoin Conferences & Events

Bitcoin Airdrops & Discovery

Bitcoin Gambling & Casinos

Related guides

Start from here →
What is Bitcoin?

What is Bitcoin?

Get a straightforward introduction to Bitcoin and why it matters.

Read this article →
What is Bitcoin?

What is Bitcoin?

Get a straightforward introduction to Bitcoin and why it matters.

How do bitcoin transactions work?

How do bitcoin transactions work?

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 →
How do bitcoin transactions work?

How do bitcoin transactions work?

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.

How do I send bitcoin?

How do I send bitcoin?

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 →
How do I send bitcoin?

How do I send bitcoin?

Sending bitcoin is as easy as choosing the amount to send and deciding where it goes. Read the article for more details.

How do I receive bitcoin?

How do I receive bitcoin?

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 →
How do I receive bitcoin?

How do I receive bitcoin?

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.

What is a confirmation

What is a confirmation

Find out about blockchain confirmations, why they are important, and more.

Read this article →
What is a confirmation

What is a confirmation

Find out about blockchain confirmations, why they are important, and more.

What are Bitcoin network fees?

What are Bitcoin network fees?

Discover what bitcoin fees are, how fees are determined, and more.

Read this article →
What are Bitcoin network fees?

What are Bitcoin network fees?

Discover what bitcoin fees are, how fees are determined, and more.

check icon
TRUSTED BY OVER 5 MILLION CRYPTO USERS WORLDWIDE

STAY AHEAD IN CRYPTO

DELIVERED WEEKLY
DELIVERED WEEKLY

Stay ahead in crypto with our weekly newsletter delivering the insights that matter most

news icon

Weekly crypto news, curated for you

insights icon

Actionable insights and educational tips

products icon

Updates on products fueling economic freedom

Sign up

No spam. Unsubscribe anytime.

Start investing safely with the Bitcoin.com WalletStart investing safely with the Bitcoin.com WalletStart investing safely with the Bitcoin.com Wallet

Start investing safely with the Bitcoin.com Wallet

Over wallets created so far

Everything you need to buy, sell, trade, and invest your Bitcoin and cryptocurrency securely

App StoreGoogle PlayQR Code
Download App