Close Menu
  • Coins
    • Bitcoin
    • Ethereum
    • Altcoins
    • NFT
  • Blockchain
  • DeFi
  • Metaverse
  • Regulation
  • Other
    • Exchanges
    • ICO
    • GameFi
    • Mining
    • Legal
  • MarketCap
What's Hot

Dubai and UAE move to align crypto frameworks under new partnership

09/08/2025

Upbit and Bithumb Soar While Coinone Sells Assets

09/08/2025

Ethena USDe Tops $5.7B, Ranks Third in Synthetic Dollars

09/08/2025
Facebook X (Twitter) Instagram
  • Back to NBTC homepage
  • Privacy Policy
  • Contact
X (Twitter) Telegram Facebook LinkedIn RSS
NBTC News
  • Coins
    1. Bitcoin
    2. Ethereum
    3. Altcoins
    4. NFT
    5. View All

    Price Breaks All-Time High Record Again – Here’s What We Know

    04/08/2025

    Bitcoin Switzerland? El Salvador to Host First Fully Native Bitcoin Capital Markets

    04/08/2025

    Bitcoin Breaks $119K, but XLM and HBAR Aren’t Impressed by Its Meager Percentage Gain

    04/08/2025

    High-Stakes Consolidation Could Define Q3 Trend

    04/08/2025

    ETH Going to $16K in This Cycle? Analyst Explains Why This Could happen

    09/08/2025

    Limited pressure from unrealized profits spark talk of sustained ETH rally

    09/08/2025

    ETH Eyes Break Above $4K, But a Few Hurdles Remain

    09/08/2025

    ETH ticks up as whales buy, exchange reserves hit 9-year low

    09/08/2025

    The Sui Ecosystem’s Top 3 Altcoin Performers

    29/07/2025

    Floki Launches $69000 Guerrilla Marketing Challenge With FlokiUltras3

    28/07/2025

    Crypto Beast denies role in Altcoin (ALT) crash rug pull, blames snipers

    28/07/2025

    $1.6 Billion XRP Surge: Here’s What’s Unfolding

    28/07/2025

    DeFi soars with tokenized stocks, but user activity shifts to NFTs: Report

    09/08/2025

    NFT market rebounds in July, surpassing DeFi in user activity

    08/08/2025

    La Poste launches a new collection of NFT stamps

    07/08/2025

    Bored Ape minter finally sells after 92% fall from peak

    07/08/2025

    Dubai and UAE move to align crypto frameworks under new partnership

    09/08/2025

    Upbit and Bithumb Soar While Coinone Sells Assets

    09/08/2025

    Ethena USDe Tops $5.7B, Ranks Third in Synthetic Dollars

    09/08/2025

    Galaxy Digital Warns Crypto Treasury Firms Create ‘Structurally Fragile’ Market

    09/08/2025
  • Blockchain

    Stability World AI Partners with SentrAI to Transform the Future of Tokenized AI Personas

    08/08/2025

    Base blames faulty sequencer for 33-minute outage, fixes made

    08/08/2025

    Switchboard launches Surge, Solana’s fastest oracle yet

    08/08/2025

    Walrus Integrates Pipe Network to Cut Latency and Enhance Bandwidth Across Chains

    08/08/2025

    Marex Becomes First Clearing Firm to Adopt JPMorgan’s Kinexys With Brevan Howard Digital

    08/08/2025
  • DeFi

    Ethena USDe Tops $5.7B, Ranks Third in Synthetic Dollars

    09/08/2025

    DeFi lending starts with stablecoins, and the GENIUS Act makes them stronger

    09/08/2025

    Hyperliquid tops $319B July volume, a record for any DeFi perp DEX

    08/08/2025

    WLFI gears up to launch its USD1 stablecoin rewards program, here’s how to earn points

    08/08/2025

    Keyring Brings Zero-Knowledge ID Layer to DeFi Vaults on Avalanche

    08/08/2025
  • Metaverse

    The Sandbox Game Maker: Unleashing Revolutionary Metaverse Experiences

    07/08/2025

    Where Has the Metaverse Gone? Examining a Failed (and Costly) Trend

    01/08/2025

    From Metaverse to Machine Learning, Inside Meta’s $72 Billion AI Gamble

    31/07/2025

    AntVerse Integrates Terminus to Transform AI-Powered Metaverse with Web3 Payments

    25/07/2025

    The Sandbox Launches Largest LAND Auction Using GBM Protocol

    21/07/2025
  • Regulation

    Galaxy Digital Warns Crypto Treasury Firms Create ‘Structurally Fragile’ Market

    09/08/2025

    Devastating PEPE Trading Losses: James Wynn’s $1M Setback

    09/08/2025

    A Deep Dive into Machi Big Brother’s $11.9M Unrealized Drawdown

    09/08/2025

    Nasdaq-Listed Cemtrex Unleashes Bold $10M Plan

    09/08/2025

    “If He Doesn’t Lower Interest Rates, the Fed Board of Governors Should Take Control”

    09/08/2025
  • Other
    1. Exchanges
    2. ICO
    3. GameFi
    4. Mining
    5. Legal
    6. View All

    Upbit and Bithumb Soar While Coinone Sells Assets

    09/08/2025

    Coinbase dYdX Support Unlocks Massive Opportunities on Native Network

    09/08/2025

    Coinbase to levy 0.1% fee for USDC to US dollar swaps over $5M

    09/08/2025

    KuCoin TR Submits SPK License Application Amid Türkiye’s Crypto Regulation Drive

    09/08/2025

    ICO for bitcoin yield farming chain Corn screams we’re so back

    22/01/2025

    Why 2025 Will See the Comeback of the ICO

    26/12/2024

    CodexField and Salvo Unite to Tokenize Game Code

    07/08/2025

    Animoca Brands Partnership Unveils Revolutionary Web3 Gaming Future

    06/08/2025

    VitaminAi and WildGo Partner to Unveil Web3 Pinball Game

    06/08/2025

    Shrapnel to Leave Avalanche in New Partnership with Gala Games

    05/08/2025

    Canaan Exits Kazakhstan and South Texas Sites Amid Bitcoin Mining Fleet Reshuffle

    09/08/2025

    Bitcoin’s Hashrate Roars to 976 EH/S — Just a Hair From 1 ZH/s Glory

    09/08/2025

    Q2 Results Reveal Strategic Shifts

    09/08/2025

    Jack Dorsey’s Block set to release new Bitcoin mining chips next week

    09/08/2025

    Dubai and UAE move to align crypto frameworks under new partnership

    09/08/2025

    Hong Kong’s stablecoin KYC rules leaves industry observers concerned

    09/08/2025

    India Chases Crypto Tax Evaders With Over 44,000 Warning Notices

    09/08/2025

    BestChange restrictions lifted as popular crypto exchange aggregator returns to Russia

    09/08/2025

    Dubai and UAE move to align crypto frameworks under new partnership

    09/08/2025

    Upbit and Bithumb Soar While Coinone Sells Assets

    09/08/2025

    Ethena USDe Tops $5.7B, Ranks Third in Synthetic Dollars

    09/08/2025

    Galaxy Digital Warns Crypto Treasury Firms Create ‘Structurally Fragile’ Market

    09/08/2025
  • MarketCap
NBTC News
Home»Bitcoin»Bitcoin OP_CAT use cases series #4: Recursive covenants
Bitcoin

Bitcoin OP_CAT use cases series #4: Recursive covenants

NBTCBy NBTC19/07/2024No Comments4 Mins Read
Share
Facebook Twitter LinkedIn Pinterest Email


This post was first published on Medium.

Recursive covenants

As we explained in series #1, a Bitcoin covenant is a mechanism that allows the sender of a Bitcoin transaction to impose certain conditions on how the receiver can spend the coins.

A recursive covenant is a type of covenant that applies not only to the immediate transaction but also to any subsequent transactions that spend the bitcoins. This means that the conditions imposed by the covenant could be enforced recursively in perpetuity.

The main difference between a regular non-recursive covenant and a recursive covenant is the scope of the conditions. A regular covenant only applies to the immediate next transaction, while a recursive one extends to all future transactions that spend the bitcoins.

Here’s a simple example to illustrate the difference:

  • Regular covenant: Alice sends Bob 1 BTC with the condition that Bob can only spend the BTC if he provides a valid signature from a specific public key. This condition only applies to the immediate transaction.
  • Recursive covenant: Alice sends Bob 1 BTC with the condition that Bob can only spend the BTC if he provides a valid signature from a specific public key, and that any future transactions spending the BTC must also provide a valid signature from the same public key. This condition applies to all future transactions that spend the BTC.

Recursive covenants can be more powerful and flexible than regular covenants. They represent a significant step forward in the programmability and flexibility of Bitcoin transactions, potentially opening up a wide array of new applications and use cases. For instance, they allow implementing more complex transaction logic required for interoperability with sidechains or other Layer 2 solutions.

Bitcoin smart contracts with state

In Bitcoin’s UTXO model, smart contracts are inherently one-off and stateless, as the UTXO containing the contract is consumed and destroyed when spent. Recursive covenants introduce a form of state that can be maintained and updated across multiple transactions. When a transaction spends a UTXO (Unspent Transaction Output) containing a stateful contract, the state of the contract is updated, and the new state is stored in the output of the spending transaction, all enforced by recursive covenants. Unlike traditional Bitcoin transactions, which are stateless and immutable once confirmed, stateful smart contracts enable the tracking and modification of state over time, akin to smart contracts on other blockchain platforms like Ethereum.

Let us illustrate how it works with a simple counter contract. This basic contract maintains a single state: how many times it has been called since deployment.

TX0, TX1 and TX2 screenshot

Counter in a chain of transactions with state 0, 1, and 2

The state is stored in an adjacent output next to the output containing the contract itself. More specifically, it is in an OP_RETURN output.

OP_RETURN OP_PUSHBYTES [counter value]

The Counter contract below resides in a Taproot output. There are two tricks worth highlighting:

  1. We choose to store state in a separate output, instead of the same taproot output. This allows us to avoid tweaking the taproot address in the contract, since the address remains unchanged. Tweaking involves heavy elliptic curve arithmetic, which necessitates either excessively long script or new opcode like OP_TAPLEAF_UPDATE_VERIFY/OP_TLUV.
  2. We use covenant to get the txid of the previous transaction, which in turns allows us to parse the raw transaction and access its outputs.

Counter contract

The contract ensure the spending transactions satisfy the following properties:

  • recursive covenant: the address of the first input is identical to the address of the first output
  • state transition: the second output (i.e., the state output) of the current transaction must have a counter value exactly one larger than that in the previous transaction’s second output
  • having one input and one two outputs

A single run results in the following transactions:

  • Deploy Transaction ID with initial state 0: https://mempool.space/signet/tx/142782e6dd8ffcf06554b8222637c237a65f47aab27c373da3ddd7b46cd8428c?source=post_page—–6a3127a24af4——————————–
  • Transaction ID with state 1 after incremented once: https://mempool.space/signet/tx/1d1112a7ba7d3dde969006ab3984564b67b5060d1d323d2d2bf963069b600f20?source=post_page—–6a3127a24af4——————————–
  • Transaction ID with state 2 after incremented twice: https://mempool.space/signet/tx/01a5ed59ec9497ec82d80dc2ba41025342d66a25eec6b4046ec5b8c4964295d1?source=post_page—–6a3127a24af4——————————–

Full code can be found at https://github.com/sCrypt-Inc/scrypt-btc-counter.

More sophisticated state machines can be implemented similarly, where state transition is enforced entirely on chain. There can be alternative places and ways to store and encode states, different from the counter contract.

Watch: Tokens on Bitcoin? One Sat Ordinals and sCrypt

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
NBTC

Related Posts

Price Breaks All-Time High Record Again – Here’s What We Know

04/08/2025

Bitcoin Switzerland? El Salvador to Host First Fully Native Bitcoin Capital Markets

04/08/2025

Bitcoin Breaks $119K, but XLM and HBAR Aren’t Impressed by Its Meager Percentage Gain

04/08/2025

High-Stakes Consolidation Could Define Q3 Trend

04/08/2025
Add A Comment

Comments are closed.

Top Posts
Get Informed

Subscribe to Updates

Get the latest news from NBTC regarding crypto, blockchains and web3 related topics.

Your source for the serious news. This website is crafted specifically to for crazy and hot cryptonews. Visit our main page for more tons of news.

We're social. Connect with us:

Facebook X (Twitter) LinkedIn RSS
Top Insights

Dubai and UAE move to align crypto frameworks under new partnership

09/08/2025

Upbit and Bithumb Soar While Coinone Sells Assets

09/08/2025

Ethena USDe Tops $5.7B, Ranks Third in Synthetic Dollars

09/08/2025
Get Informed

Subscribe to Updates

Get the latest news from NBTC regarding crypto, blockchains and web3 related topics.

Type above and press Enter to search. Press Esc to cancel.