Skip to content

Instantly share code, notes, and snippets.

@Flouse
Last active June 4, 2024 05:48
Show Gist options
  • Save Flouse/c5f81492b80734d0cf177568b1866eea to your computer and use it in GitHub Desktop.
Save Flouse/c5f81492b80734d0cf177568b1866eea to your computer and use it in GitHub Desktop.
Simple Technical Guide for RGB++ Development

Simple Technical Guide for RGB++ Development

RGB++ Code Examples

Components

RGB++ Asset Workflow Overview

  1. Creation of rgbpp_ckb_tx_virtual using @rgbpp-sdk/ckb

    1. BTC → BTC
    2. BTC → CKB
    3. CKB → BTC (isomorphic rgbpp_btc_tx is not required in this workflow)

Important

It's recommended to store the rgbpp_ckb_tx_virtual locally in case you need it in the future.

  1. Creation of rgbpp_btc_tx through @rgbpp-sdk/btc

    1. construct isomorphic rgbpp_btc_tx based on rgbpp_ckb_tx_virtual and rgbpp commitment
    2. sign and broadcast rgbpp_btc_tx to obtain rgbpp_btc_txid
  2. JoyID or dApp sends rgbpp_btc_txid and rgbpp_ckb_tx_virtual to RGB++ CKB transaction Queue (API Endpoint: /rgbpp/v1/transaction/ckb-tx)

  3. RGB++ CKB transaction Queue will process the following things:

    1. verify the received requests
    2. continuously fetch request from the queue through a cron job
    3. check whether the confirmations of req.rgbpp_btc_txid is sufficient
    4. generate the witnesses for RgbppLocks in the rgbpp_ckb_tx_virtual
    5. add a paymaster cell into rgbpp_ckb_tx_virtual.inputs if the CKB capacity is insufficient
      1. need to verify the existence of paymaster UTXO in the rgbpp_btc_tx
      2. sign the paymaster cell and the entire transaction if needed
    6. finalize the rgbpp_ckb_tx_virtual to a rgbpp_ckb_tx
    7. broadcast rgbpp_ckb_tx and mark the job as completed upon tx-confirmation

Notes

  • The RGB++ CKB transaction Queue is designed to streamline the transaction workflow. Developers have the option to implement its features by themselves without limitation.

Another Cron Job

  • btc_time_lock → target_ckb_address automation for the BTC → CKB workflow
    • every 10 minutes, a cron job queries mature btc_time_lock cells, which means the related btc_txid in btc_time_lock.args has 6+ confirmations
    • construct a transaction converting the mature btc_time_lock cells to the target_ckb_addresses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment