# Script

> scripting system for Bitcoin transactions

**Wikidata**: [Q96472816](https://www.wikidata.org/wiki/Q96472816)  
**Source**: https://4ort.xyz/entity/script

## Summary
Script, also known as Bitcoin Script, is a stack-oriented and concatenative programming language used to define the conditions under which Bitcoin transactions can be spent. It is a core component of the Bitcoin protocol, enabling features like multisignature wallets and time-locked transactions.

## Key Facts
- Script is a **stack-oriented programming language**, meaning it relies on a stack machine model for execution.
- It is also classified as a **concatenative programming language**, where operations are composed by concatenation rather than function application.
- Script is **influenced by Forth**, an earlier stack-based programming language.
- It is **used by Bitcoin (Q131723)** as its primary scripting system for transaction validation.
- The language is documented in resources like [learnmeabitcoin.com](https://learnmeabitcoin.com/technical/script/) and discussed on platforms such as [Bitcoin Stack Exchange](https://bitcoin.stackexchange.com/tags/script).
- Script enables advanced Bitcoin features, including **multisignature transactions**, as highlighted by sources like *heise online*.

## FAQs
### Q: What is Bitcoin Script used for?
A: Bitcoin Script is used to define the conditions under which Bitcoin transactions can be spent. It enables features like multisignature wallets, time locks, and other custom spending rules.

### Q: Is Bitcoin Script a Turing-complete language?
A: No, Bitcoin Script is intentionally **not Turing-complete** to ensure predictable execution and prevent infinite loops, which is critical for security in financial transactions.

### Q: What programming paradigms does Bitcoin Script follow?
A: Bitcoin Script follows **stack-oriented** and **concatenative** programming paradigms, meaning it processes operations using a stack and composes functions through concatenation.

### Q: How does Bitcoin Script differ from other scripting languages?
A: Unlike general-purpose scripting languages, Bitcoin Script is **non-Turing-complete** and designed specifically for Bitcoin transaction validation, with a focus on security and determinism.

### Q: Where can I learn more about Bitcoin Script?
A: You can learn more from resources like [learnmeabitcoin.com](https://learnmeabitcoin.com/technical/script/) or the [Bitcoin Stack Exchange](https://bitcoin.stackexchange.com/tags/script).

## Why It Matters
Bitcoin Script is a foundational component of the Bitcoin network, enabling secure and programmable transaction conditions without requiring a Turing-complete language. By restricting complexity, it prevents vulnerabilities like infinite loops while still allowing for advanced features such as multisignature wallets and time-locked transactions. This balance between flexibility and security is crucial for Bitcoin’s role as a decentralized financial system. Script’s design also influences other blockchain scripting languages, making it a key reference in the broader cryptocurrency ecosystem.

## Notable For
- **Non-Turing-complete design**: Ensures predictable execution and security in financial transactions.
- **Stack-oriented model**: Uses a stack-based approach for efficient and deterministic processing.
- **Multisignature support**: Enables shared control over funds, enhancing security for wallets.
- **Influence from Forth**: Draws inspiration from the stack-based Forth language, adapting it for blockchain use.
- **Core to Bitcoin’s protocol**: Integral to defining transaction validity rules in the Bitcoin network.

## Body
### Overview
Bitcoin Script is a domain-specific language embedded in the Bitcoin protocol. It is used to create **locking scripts** (scriptPubKey) and **unlocking scripts** (scriptSig), which determine how and when bitcoins can be spent.

### Technical Characteristics
- **Stack-based execution**: Operations push and pop values from a stack, similar to languages like Forth.
- **Concatenative nature**: Programs are formed by concatenating words (commands) rather than nesting functions.
- **Limited opcodes**: Includes a restricted set of operations to prevent complexity and ensure security.
- **No loops**: Deliberately lacks looping constructs to avoid non-termination.

### Use Cases
- **Multisignature transactions**: Requires multiple signatures to authorize a spend, useful for shared accounts or escrow.
- **Time locks**: Restricts spending until a specific block height or timestamp is reached.
- **Pay-to-Script-Hash (P2SH)**: Allows complex scripts to be hashed and embedded in a simpler address format.

### Influences and Comparisons
- **Influenced by Forth**: Shares Forth’s stack-based model but is simplified for Bitcoin’s needs.
- **Compared to AutoIt/Pascal Script**: Unlike general-purpose scripting languages, Bitcoin Script is highly specialized and lacks features like variables or loops.

### Documentation and Community
- Primary documentation is available at [learnmeabitcoin.com](https://learnmeabitcoin.com/technical/script/).
- Active discussion occurs on [Bitcoin Stack Exchange](https://bitcoin.stackexchange.com/tags/script).
- Covered in technical articles, such as *heise online*’s piece on multisignature wallets.

## Schema Markup
```json
{
  "@context": "https://schema.org",
  "@type": "Thing",
  "name": "Script",
  "alternateName": "Bitcoin Script",
  "description": "A stack-oriented and concatenative scripting system for Bitcoin transactions.",
  "url": "https://learnmeabitcoin.com/technical/script/",
  "sameAs": [
    "https://www.wikidata.org/wiki/Q131723",
    "https://bitcoin.stackexchange.com/tags/script"
  ],
  "additionalType": [
    "https://www.wikidata.org/wiki/Q754285",  // stack-oriented programming language
    "https://www.wikidata.org/wiki/Q5168445"  // concatenative programming language
  ]
}