Skip to main content

Tapscript | Bitcoin Glossary | Mapping Bitcoin

Tapscript

Protocolo

Also known as: BIP342

The updated script execution rules introduced by BIP342 as part of the Taproot upgrade. Tapscript modifies several opcodes and introduces new ones for use within Taproot script-path spends, enabling more flexible and efficient smart contracts on Bitcoin.

Overview

Tapscript (BIP342) defines the scripting rules used within Taproot script-path spends. While building on the foundation of Bitcoin Script, Tapscript introduces important modifications that improve flexibility, efficiency, and future upgradeability. It applies exclusively to scripts executed via the script-path of a P2TR output.

Key Changes from Legacy Script

Tapscript makes several notable modifications to the scripting system:

  • Schnorr-based signature validation: Replaces OP_CHECKSIG and OP_CHECKMULTISIG semantics with Schnorr-based equivalents. The new OP_CHECKSIGADD opcode replaces OP_CHECKMULTISIG with a more efficient batch-verifiable design.
  • Signature size: All Schnorr signatures in Tapscript are exactly 64 bytes (or 65 with a sighash flag), simplifying fee estimation.
  • OP_SUCCESSx opcodes: Previously undefined opcodes are designated as OP_SUCCESS, making any script containing them automatically succeed. This provides a clean mechanism for future soft fork upgrades to assign new functionality to these opcodes.
  • Removed opcodes: OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY are disabled in Tapscript in favor of OP_CHECKSIGADD.

Script-Path Execution

Taproot Output
      |
  Script-path spend:
      |
  ┌───────────────────────────┐
  │ 1. Reveal the script      │
  │ 2. Provide Merkle proof   │
  │ 3. Execute Tapscript      │
  │ 4. Validate against rules │
  └───────────────────────────┘

When a script-path spend is used, the spender reveals the specific script leaf and provides a Merkle proof showing it is part of the committed script tree. The script is then executed under Tapscript rules rather than legacy Bitcoin Script rules.

Future Upgradeability

One of Tapscript's most important design features is the OP_SUCCESS mechanism. Because any script containing an OP_SUCCESS opcode unconditionally succeeds, a future soft fork can redefine these opcodes to add new conditions. This provides a much cleaner upgrade path than the legacy OP_NOP extension mechanism, which could only add new restrictions.

Common Misconceptions

Tapscript is not a completely new scripting language — it is a modified version of Bitcoin Script with specific rule changes for the Taproot context. Most existing opcodes behave identically in both systems.