Build
Programming with UTXO and Inscription

Programming with Bitcoin's UTXO and Inscription

In Rooch, Bitcoin's UTXO and Inscription are parsed into Move's Object (opens in a new tab), allowing developers to manipulate Bitcoin's UTXO and Inscription via Object-related APIs.

Atomic State Binding

Rooch implements atomic binding between Bitcoin state and Rooch L2 state through the nesting capabilities of Move's Object.

Atomic-binding UTXO

For example, the UTXO X shown above is expressed as an Object in Move, which includes a Temporary area. The states nested within this area are cleared when the UTXO is spent. This is akin to RGB's "one-time seals," leveraging the fact that a UTXO can only be spent once. For instance, an application that offers Bitcoin mining features might store user's stake information in this area, which gets lost once the UTXO is consumed. If the protocol supports UTXO mapping tracking, a Permanent Area can be provided to facilitate atomic transfers of state between L1 and L2.

Atomic-binding Inscription

As shown above, this represents a Bitcoin blockchain state in Move, such as an Ordinals Inscription (similar to RGB). Its Permanent Area can hold permanent states, such as Coins or NFTs. When the Inscription is transferred on L1, the states in the Temporary Area are cleared, but those in the Permanent Area are retained and transferred to the new owner.

Programming with UTXO

💡

TODO: This section of the document needs improvement

  1. Explanation of UTXO fields
  2. How to accept UTXO as method parameters
  3. How to store data in the UTXO's temporary area

Examples

  1. btc_holder_coin (opens in a new tab): A simple UTXO example that implements token distribution based on the duration a Bitcoin is held.
  2. btc_holder_farmer (opens in a new tab): A more complex UTXO example that implements token rewards for Bitcoin holders through a DeFi farmer model.

Programming with Inscription

💡

TODO: This section of the document needs improvement

  1. Explanation of Inscription fields
  2. How to accept Inscription as method parameters
  3. How to store data in the Inscription's temporary and permanent areas

Examples

  1. bitcoin_plants (opens in a new tab): A simple Inscription example that implements a game on Layer2 where Bitcoin Inscriptions serve as seeds to grow plants. Ownership of the plant transfers along with the Inscription.