How MATT and OP_CCV Could Carry Contract State Across Bitcoin Transactions

How MATT and OP_CCV Could Carry Contract State Across Bitcoin Transactions

N
News Editor
2026-11-11 13:26:18
Cointelegraph Research’s fifth article on Bitcoin covenants examines MATT, or Merkleize All The Things, and its most direct implementation through OP_CHECKCONTRACTVERIFY, known as OP_CCV. The proposal would let Bitcoin contracts carry data from one transaction to the next instead of evaluating every transaction without memory of earlier executions. OP_CCV commits contract state into Taproot output keys. A script can inspect state supplied on the witness stack, calculate an updated value, and require the next output to commit to that value. The article describes default, deduct and ignore modes for checking outputs, along with a separate input mode. Default and deduct modes preserve value across checked outputs, so fees can be paid through dedicated inputs without forcing preset amounts or accidentally burning funds. The article also examines OP_CCV combined with OP_CAT. Byte concatenation would allow scripts to verify Merkle proofs against a separate contract state tree, update its root and commit the new root in the next output. That construction could support compact fraud proofs, with only a disputed computation step revealed onchain. The combination also expands OP_CCV’s vault capabilities toward the functionality proposed by OP_VAULT. The next article will cover application-specific opcodes including OP_VAULT, OP_UNVAULT and OP_EVICT.

Cointelegraph Research’s fifth article in its Bitcoin covenant series examines MATT, short for Merkleize All The Things, and OP_CHECKCONTRACTVERIFY, or OP_CCV. The proposal would let OP_CCV embed contract state directly into Taproot output keys and enforce valid state transitions onchain. That creates a path toward stateful contracts and compact fraud proofs on Bitcoin.

A stateful contract carries information across multiple transactions and updates that information as the contract develops. Standard Bitcoin scripts do not offer that capability: each transaction is evaluated independently, with no memory of previous executions.

MATT and the limits of predetermined states

Covenant proposals can make UTXOs carry state to some extent. The article points to Sapio, a scripting language built on OP_CTV, as an example. Sapio uses addresses to represent a finite-state automaton, while transactions act as transitions between states.

That model does not provide an elegant way to implement numerical logic. MATT addresses the gap, especially through its proposed OP_CCV implementation. Because MATT can compute committed data at spend time and embed the result into the next output, each spend can derive a new state dynamically. It does not have to select one state from a predetermined list.

Committing state to a Taproot key

Taproot already provides a way to commit data through public keys. Every Taproot output contains a base public key called the internal key. The key can be cryptographically modified, or tweaked, to commit to additional information. Formally, the tweaked key is Q = P + t·G. Here, P is the internal key, G is the generator of the secp256k1 elliptic curve, and t is a tagged hash of P and the data being committed.

In a regular Taproot output, this commitment usually encodes the Merkle root of a taptree containing hidden spending paths. MATT builds on that mechanism by placing contract state in the key as well. Instead of putting complex logic directly into Bitcoin’s scripting language, MATT expresses computation as a sequence of state commitments. The chain then checks whether each transition is valid.

MATT can be implemented through different combinations of opcodes. The most direct and best-specified route relies on OP_CCV. The opcode provides the primitive needed for state-carrying UTXOs within Taproot. OP_CCV lets a script check whether a Taproot input or output key has been tweaked to commit to a specified piece of state data.

The internal key is first tweaked with a hash of the contract’s current state. Taproot’s standard taptree tweak is then applied on top. The resulting output key commits to both the tapscript — the set of spending conditions — and the contract’s current state.

OP_CCV can enforce the state that moves into the next output. The script can inspect state data placed on the witness stack, perform calculations on that data and require the updated state to be correctly re-committed in a specified output. That is the mechanism for enforcing state transitions onchain.

The stack format is:

<data> <index> <pk> <taptree> <mode> OP_CHECKCONTRACTVERIFY

The opcode supports three modes for checking an output, as well as a separate input mode.

  • In default mode, the input UTXO’s entire BTC value is assigned to the specified output.
  • In deduct mode, only an amount equal to the output’s value is assigned, leaving the remainder available for additional outputs.
  • In ignore mode, the script and data commitment are checked without imposing an amount constraint.

Default and deduct modes are designed to preserve value through checked outputs. Transaction fees must consequently be paid through separate fee-paying inputs. A transaction can include a dedicated fee input and a change output without conflicting with the covenant’s constraints.

This avoids the accidental fund burning that can occur with more primitive covenant implementations such as OP_CTV or SIGHASH_ANYPREVOUT. It also addresses a major limitation of presigned-transaction-style covenants. Those designs typically set amounts in advance, which prevents dynamic fee adjustments and partial unvaults.

OP_CCV plus OP_CAT for Merkle and fraud proofs

The full MATT framework becomes more expressive when OP_CCV is combined with OP_CAT. OP_CAT enables byte concatenation in Script, making it possible to construct and verify Merkle proofs directly onchain.

The arrangement associates two distinct Merkle trees with a Taproot output. The first is the familiar Taproot script tree, or taptree, whose leaves are the contract’s spending scripts. The second is a separate state tree. Its leaves contain contract data, such as intermediate steps in a computation.

An OP_CCV plus OP_CAT script can verify a Merkle proof against the current state-tree root. It can then calculate the updated root after a transition and use OP_CCV to force the next output to commit to that root.

The construction supports fraud-proof systems with a slashing condition. A long computation can be committed offchain, while only the disputed step and its path through the binary tree need to be disclosed and verified onchain. Similar systems exist as optimistic rollups on other blockchain systems: the full computation runs offchain, and the onchain contract intervenes only after someone raises a challenge.

Fraud proofs require the computation to be compiled into a binary circuit or another step-by-step representation that can be committed to a Merkle tree. OP_CCV plus OP_CAT would avoid the Lamport one-time signatures and presigned transaction graphs that BitVM relies on to enforce state consistency.

Implications for vaults

The article also discusses vaults. OP_CCV alone can implement vaults, but adding OP_CAT allows fully featured vaults that are essentially equivalent to the functionality proposed by OP_VAULT.

James O’Beirne, the author of OP_VAULT, has said that OP_CCV is a more general and robust design that effectively supersedes his earlier proposal.

The next article in the series will move from general covenant proposals to application-specific opcodes, including OP_VAULT, OP_UNVAULT and OP_EVICT. Each is designed to address a specific problem rather than provide broad programmability.

This article was originally published by Bit.Fan. For more cryptocurrency news and market insights, visit www.bit.fan.
100

Disclaimer:

The market information, project data, and third-party content displayed on this platform are for industry information sharing only and do not constitute any form of investment advice or return commitment.

Cryptocurrency trading carries high risks. Users should fully assess their risk tolerance and make independent decisions. All profits, losses, and legal responsibilities are borne by the users themselves.

How MATT and OP_CCV Could Carry Contract State Across Bitcoin Transactions | Bit.Fan