BitcoinMachine
TERM_DEF // SCRIPT_AUTHORIZATION / OP_CHECKTEMPLATEVERIFY_OP_CTV_BIP_119
OP_CHECKTEMPLATEVERIFY / OP_CTV
(BIP 119)
OP_CHECKTEMPLATEVERIFY / OP_CTV (BIP 119). Proposed covenant opcode committing to the exact shape of the spending transaction.

This page sits in the Script & Authorization section — The stack VM that decides whether a UTXO is spendable — opcodes, templates, and modern script trees. Read on for what it is, why it exists, how it works under the hood, and what to watch out for.
OP_CHECKTEMPLATEVERIFY / OP_CTV (BIP 119) — at a glance
SCRIPT
OP_CHECKTEMPLATEVERIFY is a Bitcoin Script opcode in the COVENANT family. Its stack effect is h → (fail unless tx commits to h). Commit an output to a specific spending-tx hash template. Proposed covenant opcode committing to the exact shape of the spending transaction.
Why it exists
DESIGN
OP_CHECKTEMPLATEVERIFY exists because Covenants let an output dictate where its descendants can go — vault constructions, congestion control, drechain-style designs.
Mechanism
HOW IT WORKS
Every UTXO is locked by a scriptPubKey — the output's locking script. To spend it, you provide a scriptSig (or witness) containing data that satisfies the lock. The node concatenates them, runs the combined script on a stack machine, and accepts the spend if and only if execution finishes with a single truthy value on the stack. OP_CHECKTEMPLATEVERIFY / OP_CTV (BIP 119) contributes a specific stack effect within that process — opcodes either push, pop, copy, hash, branch, or verify, and they do so left-to-right deterministically.
1. The script is parsed into a sequence of opcodes and push-data items. 2. Execution starts with an empty stack and an empty alt-stack. 3. Each opcode runs in order — push opcodes add to the stack, others consume the top items and may push results. 4. When OP_CHECKTEMPLATEVERIFY / OP_CTV (BIP 119) is reached, it performs its specific stack effect (see below). 5. Final state: a single non-zero (truthy) value on top → the spend is authorised. Anything else (empty stack, false, error) → the script fails and the tx is rejected.
OP_CHECKTEMPLATEVERIFY — stack effect + canonical use
EXAMPLE
Opcode : OP_CHECKTEMPLATEVERIFY Family : COVENANT Stack effect: h → (fail unless tx commits to h) Added : BIP-119 (draft) Behaviour : Commit an output to a specific spending-tx hash template. Open /playground in another tab and search for OP_CHECKTEMPLATEVERIFY. Drag the opcode in, watch the stack visualisation step through it against any combination of inputs you choose.
FAMILY
Belongs to the COVENANT family of Script opcodes — siblings share validation rules and historical evolution.
STACK EFFECT
Exactly h → (fail unless tx commits to h). Every full node enforces the same effect, byte-for-byte.
ACTIVE
Active on mainnet today; every spend that uses it is being validated by every full node.
CONSENSUS-CRITICAL
OP_CHECKTEMPLATEVERIFY's behaviour is consensus rule — a node implementing it differently would fork off the network.
Things that catch people out
PITFALLS
  • Opcode semantics are consensus — verify against the latest Bitcoin Core source before relying on any subtle behaviour.

Other terms from Script & Authorization — click any to read its page:
TERMINOLOGY
OP_CHECKTEMPLATEVERIFY / OP_CTV (BIP 119)
Proposed covenant opcode committing to the exact shape of the spending transaction.
Script
Bitcoin's purpose-built stack language; every locking and unlocking script is a script program.
Stack
The single LIFO data structure all script execution operates on; no variables, no registers.
Locking Script
The scriptPubKey on an output; specifies the spending conditions.
Unlocking Script
The scriptSig/witness in an input; provides the data that satisfies the lock.
Redeem Script
In P2SH, the script whose HASH160 appears in the output; revealed at spend time and then executed.
Witness Script
In P2WSH, the script whose SHA256 is committed in the output; placed at the end of the witness stack.
Script Execution
Sequential stepping through opcodes, mutating the stack until either a valid truthy stack remains or the script fails.