Bitcoin OP_CCV ⚡ MATT: Stateful Contracts, Covenants & Fraud Proofs
Discover Bitcoin OP_CCV and MATT Bitcoin: stateful contracts, Bitcoin covenants, OP_CAT Bitcoin tools, and fraud proofs—plus key vault trade-offs.

How MATT and OP_CCV Could Give Bitcoin Contracts State
Bitcoin scripts can set conditions for spending coins, but they don't naturally "remember" what happened in a previous transaction. That makes some contract ideas awkward. You might want to carry a balance forward, track where a process is up to, or prove that one computation step happened before the next. Covenants can constrain where coins go - but keeping useful, changing state across transactions is a different problem.
MATT, short for Merkleize All The Things, is one proposed way to tackle that. The idea adds an OP_CHECKCONTRACTVERIFY opcode, usually called OP_CCV, so a script can check that contract state is committed in a Taproot output key and that a valid update is used in the next transaction. In combination with OP_CAT, another proposed Script capability, the design could also support compact Merkle proofs and fraud-proof-style systems.
This article walks through the problem MATT is trying to solve, what OP_CCV would do, and what the combination could enable for vaults and off-chain computation. It also flags the practical limits: these are proposals for Bitcoin protocol behavior, not things you can assume are available on Bitcoin today.
Why do Bitcoin contracts need state
A Bitcoin transaction spends existing UTXOs and creates new ones. When a UTXO is spent, the corresponding script is executed to check whether the spend satisfies its rules. By default, that script execution doesn't leave behind a mutable record you can reuse later. After confirmation, the next spend is evaluated based on its own inputs, witness data, and transaction context.
That model works well for straightforward transfers and many spending policies. It gets trickier when an application needs to carry a changing value forward. Think of a contract that records how far a process has progressed, or a vault that moves through deposit, unvaulting, and withdrawal stages. In those cases, the contract needs to show that the new state follows from the old one - not just that the next transaction spends the same coins.
The limits of fixed state paths
Some covenant designs represent "state" by listing allowed transaction paths ahead of time. Outputs (or addresses) correspond to states, and transactions move coins from one state to another. In practice, it's like a finite-state machine where the transitions are planned in advance.
This can work when the number of states is small and you know the possibilities ahead of time. It's less convenient for numeric values or for open-ended updates. If a contract needs to support many possible balances or computation results, encoding every allowed outcome as its own predefined path quickly becomes cumbersome. The transaction graph grows with the number of cases the application must handle.
MATT aims at a different trade-off. Instead of predefining every possible transition, the contract can receive state data, do checks or calculations in Script, and require the updated result to be committed in the next output. The chain enforces the transition rule at spend time; it doesn't need to retain a separate "working memory" like a conventional virtual machine would.
What stateful means in this design
Here, "stateful" doesn't mean Bitcoin nodes run an application database in the background. The state lives as data and a cryptographic commitment tied to a UTXO. When that UTXO is spent, the witness provides the relevant state data. The spending script checks it and constrains how the next output commits to the updated state.
That's more limited than a general-purpose virtual machine. The design still depends on Bitcoin's transaction model, what Script can do, and the specific covenant rules being proposed. But it could make contracts more expressive without forcing every possible future state to be listed upfront in a long set of presigned transactions.
How does OP_CCV commit state
OP_CCV is proposed as the missing link between "contract state" and a Taproot output. Taproot already commits to information through a tweaked public key, including commitments to a tree of spending scripts. MATT extends that approach so the key can also commit to the contract state carried by the output.
From a Taproot key to a state commitment
A Taproot output starts with an internal public key. The output key is then tweaked using a value derived from committed data. In simplified form, the output key can be written as Q = P + t·G, where P is the internal key, G is the generator point on the secp256k1 curve, and t is a tagged hash derived from the internal key and the data being committed.
In ordinary Taproot, the tweak often commits to the root of a script tree, with leaves containing alternative spending conditions. In the MATT setup, a separate commitment to contract state is included too. The output key then commits to both the spending logic and the state associated with the UTXO.
A commitment isn't the same thing as putting the entire state openly inside the public key. The key binds the output to a specific value; the witness provides the data needed to prove that value and compute an update. That split matters: the commitment gives integrity, while the witness gives the material the script needs to check the transition.
Enforcing the next state
At spend time, the script can look at the provided state data, run the permitted checks, and require that a specified output commits to the resulting state. OP_CCV is intended to verify that the required tweak appears on the relevant input/output key. If the next output doesn't commit to the state produced by the transition, the spend fails.
Conceptually, the opcode uses stack items such as state data, an output or input index, a public key, a taptree value, and a mode. The exact opcode details and stack conventions are proposal-specific, so any implementation would need to follow the consensus rules that eventually get adopted.
The key point is the relationship between transactions. The current state is checked, the transition is evaluated, and the next UTXO is required to commit to the updated state. Instead of relying on an off-chain application server to report a correct transition, the chain validates the rule when the contract output is spent.
Why amount modes and fees matter
The proposal includes modes for checking outputs that handle value differently. In default mode, the input's full bitcoin value is assigned to the checked output. In deduct mode, the checked output receives the specified portion, leaving value available for other outputs. In ignore mode, the script and the state commitment can be checked without enforcing the amount in the same way. The proposal also describes an input mode.
These choices affect how transactions are constructed. If a covenant check requires the contract's value to be preserved in a particular checked output, miners' fees can't simply be deducted from that value without breaking the rule. Instead, the transaction can include a separate fee-paying input and an appropriate change output. That adds complexity, but it gives the design a way to handle fees without hard-coding every transaction amount in advance.
In other words, stronger value rules can prevent accidental value loss and support partial operations - but they also put more responsibility on wallets and contract software to build transactions correctly. OP_CCV wouldn't eliminate fee management. It would fold permitted value and fee flows into the contract rules themselves.
What does OP_CAT add to MATT
OP_CCV can tie state transitions to commitments, but pairing it with OP_CAT could make the state representation more flexible. OP_CAT is a proposed Script operation for concatenating byte strings. With the right checks, concatenation can help build and verify Merkle proofs using witness data supplied with a transaction.
Two trees with different jobs
Taproot already supports a tree of spending scripts. Its leaves represent different ways the output can be spent, and its root is committed through the Taproot key. MATT's state-tree idea is separate. Its leaves represent contract data - like computation steps or values that change as the contract progresses.
A script could take a leaf and its Merkle path, then use hashing and byte operations to verify that the leaf belongs to the state-tree root committed by the output. It could check a transition involving that leaf, compute a new root, and then use OP_CCV to require that the next output commits to the updated root.
This lets a contract reference a specific piece of a larger onchain state without revealing (or committing to) everything onchain in the same way. The witness reveals the data and proof needed for the part being contested or checked, while the commitment binds the process to the full structure.
How that could support fraud proofs
A fraud-proof system can run most computation offchain and move to onchain only when someone challenges the result. For that to work, the computation needs to be structured as verifiable steps. A Merkle tree can commit to those steps, so a challenger can reveal just the relevant step and its Merkle proof rather than publishing the entire computation.
Onchain, a verification script checks the challenged transition. If the step doesn't follow from the agreed rules, the contract can apply a consequence, such as slashing funds. This general pattern is familiar from optimistic rollup designs in other blockchain systems: the offchain result is accepted unless someone supplies a valid challenge within the required process.
The hard part isn't "just" adding a Merkle proof. The computation still needs to be expressed in a step-by-step format that a protocol can verify, and the protocol must define who can challenge, what evidence is required, and what happens if a challenge is ignored or delayed. MATT provides a proposed way to enforce commitments and transitions, but it doesn't automatically solve the incentives or the application-level design.
The OP_CCV + OP_CAT combination could reduce dependence on approaches like Lamport one-time signatures and large presigned transaction graphs used in some BitVM-style constructions. That might simplify some designs - but it's not a guarantee that any system using MATT will be smaller, cheaper, or safer. The outcome depends on the computation, the proof format, and the transaction patterns the application chooses.
What could MATT mean for vaults and applications
Vaults use staged spending rules to reduce the risk that an attacker can immediately move funds after gaining access to a key. A common pattern separates an unvaulting step from a final withdrawal, giving the owner time (or a recovery path) to respond. The actual security properties depend on the covenant rules, wallet implementation, and how the setup is run.
OP_CCV alone is proposed as a way to build vault-like policies that carry state and constrain how funds move. Adding OP_CAT could enable more elaborate state checks, including structures similar to what a dedicated vault opcode such as OP_VAULT would target. In that sense, MATT is broader: it aims to support more general stateful constructions rather than one narrowly defined vault mechanism.
Generality brings implementation costs
A general primitive can support multiple applications, but it pushes more work onto developers. Wallets must construct and validate the right witness data. Contract authors must define state formats, transition rules, and recovery paths. Users then need tools that make those policies understandable, not just a pile of raw script behavior.
There's also a security-review cost. A fixed-purpose opcode can be easier to reason about because it constrains what you can build. A general framework can express more designs - and that means more ways to get something wrong. Even if a vault enforces the intended transition, it still may be unusable if the recovery process is unclear or if users can't tell which transaction they're actually authorizing.
What has to happen before deployment
OP_CCV and the broader MATT design are proposals for Bitcoin Script and consensus behavior. They shouldn't be treated as features that existing Bitcoin transactions can already use. A real proposal would need a precise specification, review, implementation work, and broad agreement on any consensus change before users could rely on it on the Bitcoin network.
Even after activation, adoption would likely be gradual. Wallet support, how hardware signers behave, fee handling, and recovery procedures all have to work together. For institutions, the question wouldn't just be whether OP_CCV can express "a vault" or "a fraud proof." It would also be whether the full operational process can be audited, recovered, and maintained under real-world conditions.
A useful way to evaluate it is comparative: does a MATT-based construction solve a problem better than a simpler covenant, a dedicated opcode, or an offchain system with a clear trust model? Generality is valuable when it removes duplicated machinery. It's not valuable if it makes contracts too hard to verify or operate correctly.
Conclusion
MATT is aimed at a real limitation in Bitcoin contract design: scripts can enforce spending conditions, but carrying useful state from one transaction to the next isn't straightforward. OP_CCV would connect that state to Taproot output keys and require valid updates when a UTXO is spent. OP_CAT could extend the approach with Merkle proofs for selective verification and dispute processes.
If it works as described, the payoff is broader stateful contracts - potentially including more capable vaults and more compact fraud-proof systems. The trade-off is extra protocol complexity, implementation effort, and security review. The right question isn't whether more programmability is automatically better. It's whether a specific application actually benefits enough to justify the new assumptions and the operational burden. Until these proposals are specified, adopted, and supported across the Bitcoin ecosystem, they remain designs to evaluate - not ready tools for production.