Implementation of CKB Stablecoin Payment

Industry Express
2024-10-31 11:27:01
Collection
CKB is the Layer 1 blockchain of Nervos Network, and its main functions can be summarized as Consensus & Execution and Data Availability, enhancing scalability through payment channels and RGB++.

Author: Jimmie, 10K Ventures

1. Overview

  • CKB stablecoin payment is a decentralized stablecoin payment solution based on the CKB network, allowing users to generate and manage the USD-pegged stablecoin RUSD through the joint network of CKB and Bitcoin, utilizing Layer 2 extensions such as RGB++ and Fiber Network, achieving fast, low-cost, and secure cross-chain stablecoin payments.

2. Introduction to Core Components

2.1 CKB (Common Knowledge Base)

2.1.1 What is CKB

  • CKB is the Layer 1 blockchain of the Nervos Network, whose main functions can be summarized as Consensus & Execution and Data Availability, enhancing scalability through payment channels and RGB++ built on top of it.
  • It is based on the PoW consensus mechanism, similar to BTC, and adopts an upgraded version of the BTC algorithm called NC-MAX. This algorithm improves network efficiency and responsiveness by accelerating transaction confirmation times and reducing orphan block rates. Unlike BTC's fixed block interval of 10 minutes, CKB dynamically adjusts block intervals based on network activity (approximately every four hours), optimizing performance.
  • CKB uses the Eaglesong hash function, a hash function specifically tailored for the Nervos Network, providing the same level of security as SHA-256.
  • CKB employs the Cell model as the core of its data structure, which is an improved version of BTC's UTXO accounting model.
  • Through a dual-script system, it allows for more flexible data storage and verification, supporting asset issuance and smart contract execution.
  • It provides data storage and state management functions, ensuring the long-term availability of all on-chain assets and data.

2.1.2 Cell Model

  • Cell Model & Features:
  • The Cell model is similar to BTC's UTXO model but achieves on-chain data storage and verification of smart contract scripts through the introduction of dual scripts.
  • Store any type of data or asset: In BTC's UTXO model, each transaction output can only contain simple amount information and ownership; however, each Cell in CKB can store smart contract code and trigger these scripts through external calls in transactions, meaning each Cell can independently execute the smart contract logic associated with it, providing programmability.
  • Separation of state and computation: Since Cells store the code and state of smart contracts, each Cell can independently execute contract logic, while complex computation tasks can be executed on Layer 2 or off-chain, with the execution results synchronized back to Layer 1 through transactions, ensuring network security and data consistency.
  • Parallel execution & transaction packaging: Through the Cell model, smart contracts in different Cells can achieve parallel execution, while the transaction results of different Cells can be packaged and updated on-chain, making computation more efficient and reducing transaction costs.

  • How the Cell model works:

  • Cells consist of inputs and outputs: Similar to BTC's UTXO model, Cells execute transactions and state updates through inputs and outputs. Each Cell can be spent as an input in a transaction, generating new outputs and creating new Cells.
  • Elements of a Cell: Each Cell contains Capacity, Updated Data, Lock Script, and Type Script.
  • Capacity: Capacity records the size of the Cell's storage space and represents the storage value of CKByte tokens. Users creating Cells need to allocate a certain amount of Capacity based on the data volume to ensure effective utilization of on-chain storage.
  • Data: It is one of the core features of the Cell model, allowing the storage of diverse data from simple numbers to complex smart contract states on the blockchain.
  • Dual-script system:
  • Lock Script: Used for authentication, similar to BTC's signature mechanism, preventing unauthorized users from accessing or modifying data in the Cell. Users must provide the correct signature or multi-signature to unlock and use the Cell.
  • Type Script: Defines the data validation logic of the Cell, setting the rules for how the Cell can be used or modified in future transactions, determining the legality of transactions or states through the execution of smart contracts or rule validations.
  • Live Cell & Dead Cell:
  • A Live Cell refers to a Cell that has not yet been spent and can still be used as an input for the next transaction or state update.

2.1.3 Programmability & CKB-VM

  • The Cell model is the foundation of CKB's programmability: It supports storing the state and execution scripts of smart contracts in each Cell, tightly integrating contract execution and asset management.
  • Through the Turing-complete RISC-V virtual machine (CKB-VM), developers can execute custom smart contracts on-chain. The flexibility of the RISC-V instruction set gives developers more freedom to write contracts, enabling CKB to support complex contract logic.
  • CKB-VM supports multiple languages: Including popular languages such as C and Rust. This broad compatibility distinguishes CKB-VM from other blockchain virtual machines that are typically limited to specific languages, opening it up to a wider developer community. The CKB network also supports SDKs for mainstream languages like JavaScript, Rust, Go, and Java, facilitating development with familiar tools.
  • Compatibility and scalability: The design of CKB-VM ensures compatibility with BTC's UTXO model and other blockchains while supporting highly scalable smart contracts and complex applications.
  • Sources:
  • https://mp.weixin.qq.com/s/SU4ur-54yae7lqGif8704g
  • https://medium.com/nervosnetwork/an-introduction-to-ckb-vm-9d95678a7757

2.1.4 PoW Consensus Mechanism

  • CKB adopts a PoW consensus mechanism similar to BTC, ensuring the network's security and decentralization. Like BTC, miners compete to compute hash values to package blocks, ensuring the immutability and censorship resistance of the network.
  • NC-MAX algorithm: Compared to BTC, CKB introduces the improved NC-MAX algorithm. This improvement allows for higher throughput and optimizes block packaging efficiency, reducing orphan block rates and enhancing transaction confirmation speeds, making it suitable for large-scale application scenarios such as asset storage and payment settlement.
  • Eaglesong hash function: The custom design of the Eaglesong hash function provides performance and security advantages for the Nervos CKB network through ASIC neutrality, efficiency, security, and network fairness, ensuring decentralization while enhancing mining efficiency and network scalability.
  • Sources:
  • https://docs.nervos.org/docs/tech-explanation/consensus#nc-max-consensus-algorithm

2.1.5 Multi-layer Security Architecture

  • CKB adopts a multi-layer security architecture: Layer 1 focuses on the final settlement of data and the secure storage of states, while Layer 2 is used to expand transaction processing capabilities.
  • The separated architecture ensures the security of the main chain (Layer 1): Reducing the load during transaction processing improves the overall stability of the network.

2.1.6 Connection and Orthodoxy with BTC

  • Cross-chain interoperability of the UTXO model:
  • CKB's Cell model is an extension of BTC's UTXO model. This similarity allows assets on the BTC UTXO model to be cross-chain operated on CKB using cross-chain bridging tools like Force Bridge. BTC users can map their assets to the CKB network, leveraging the flexibility of the CKB network for storage, smart contract operations, and decentralized finance (DeFi) applications.
  • Since Cells are structurally similar to BTC UTXOs and CKB can be compatible with BTC's signature algorithm, users can manipulate CKB on-chain assets using BTC wallets, and the same applies to other UTXO public chains.
  • Orthodoxy: CKB maintains ideological consistency with BTC by adopting NC-Max (Nakamoto Consensus Max). NC-Max is an improved version of Nakamoto consensus, providing better security and performance.
  • Community support: The Nervos community consists of numerous blockchain technology enthusiasts, developers, and miners, and has received support from parts of the BTC community. Its orthodoxy lies in inheriting BTC's decentralization philosophy while meeting broader needs through expanded functionalities.
  • Sources:
  • https://medium.com/@NervosCN/%E7%A7%91%E6%99%AE-%E4%BB%80%E4%B9%88%E6%98%AF%E4%B8%AD%E6%9C%AC%E8%81%AA%E5%85%B1%E8%AF%86-92ffe0886104

2.1.7 The Role of CKB in Stablecoin Payments

  • Storage and management of stablecoin balances: The Cell model of CKB is the foundation for stablecoin storage, with users' stablecoin balances like RUSD stored in Cells on-chain. Each Cell contains complete balance information, ensuring the security and traceability of assets.
  • Recording transaction states: CKB supports recording every state change of transactions on-chain, allowing all payment processes to be transparently recorded and tracked through the Cell model. This mechanism is crucial in stablecoin payments, ensuring transaction security and verifiability.
  • Execution of smart contracts: Complex operations such as conditional payments and locks during stablecoin payments can be implemented through smart contracts supported by CKB-VM.

2.2 RGB++

2.2.1 What is RGB++

2.2.2 Basic Functions

  • Through RGB++, CKB acts as the shadow chain for BTC: Serving as a supplementary chain for BTC, handling complex logic and smart contract operations that BTC natively cannot process.
  • Interaction with the BTC network
  • Transaction occurrence: In the BTC network, users complete transactions through the conventional UTXO model, while parts involving smart contract execution bind contract states and data to CKB through RGB++.
  • Verification logic: Transaction records conducted on the BTC network will synchronize with the contract states stored on CKB through RGB++, ensuring the legality of transactions through specific verification logic. Whenever a transaction occurs on the network, RGB++ triggers contract execution on CKB, checking whether the transaction meets predetermined rules, such as whether the balance is sufficient, whether the signature is valid, and whether the contract conditions are satisfied.
  • RGB++ uses a client-side validation model to ensure the privacy and integrity of off-chain data, submitting data to CKB for final settlement only after off-chain validation passes.
  • Asset issuance and management: RGB++ allows users to issue assets (such as stablecoins, tokens, etc.) through off-chain protocols and use CKB to manage the lifecycle of these assets (including not only asset issuance and circulation but also more complex operations such as time locks and conditional payments).
  • RGB++ combines the high security of BTC with the programmability of CKB.

2.2.3 Isomorphic Binding

  • Cross-chain synchronization of assets & states: Isomorphic binding refers to maintaining synchronization of assets and states between BTC and CKB (or other UTXO public chains, such as Cardano) through a binding mechanism. Whenever an asset transaction occurs on the BTC chain, RGB++ maps the corresponding contract state or asset change on CKB.
  • Extended UTXO: In isomorphic binding, each UTXO on the BTC chain has a corresponding Cell (UTXO container) on CKB, recording the corresponding asset state and smart contract conditions.
  • Asset binding: When a user holds a certain RGB++ asset on the BTC chain, the corresponding Cell on CKB will store the relevant asset state, ensuring consistency of asset information between the two chains through isomorphic binding.
  • Transaction synchronization: When RGB++ token transactions occur, the isomorphic binding mechanism generates a Commitment on the BTC network, consuming the corresponding Cell on the CKB chain, while new Cells are created to allocate assets.
  • Advantages of isomorphic binding - Empowering BTCFi
  • Smart contract support: BTC cannot natively support Turing-complete smart contracts, but through isomorphic binding, CKB can serve as the execution layer for smart contracts, managing complex transaction conditions for BTC assets, such as time locks and conditional payments.
  • Flexibility in asset management: Isomorphic binding allows for the management of assets circulating in the BTC network on CKB, enabling users to execute complex financial operations through CKB's flexible programming capabilities without changing the underlying BTC protocol.

2.2.4 Leap

  • RGB++ Layer upgrade proposal: Extending the binding relationship between CKB and BTC to all UTXO chains, enabling cross-chain asset transfers through "re-binding."
  • Bridge-less cross-chain between BTC and other UTXO chains: Its core purpose is to allow RGB++ assets on the BTC chain to seamlessly transfer to other UTXO chains by switching the binding UTXO of assets, supporting asset management and transfer across multiple blockchains.
  • Bridge-less technology: Leap achieves cross-chain asset transfer through isomorphic binding technology and switching UTXOs across different chains, without relying on traditional lock-mint cross-chain bridges.
  • Operational process: For example, users can control RGB++ assets originally on the BTC chain through the Cardano chain and perform asset splitting and transfers on the Cardano chain.
  • Publishing Commitment: First, users need to publish a Commitment on the BTC chain, declaring the intention to unbind the assets bound to the BTC UTXO.
  • Binding on the Cardano chain: Next, publish a new Commitment on the Cardano chain to bind the RGB++ asset to Cardano's eUTXO.
  • Modifying the lock script: Then, modify the lock script of the RGB++ asset on the CKB chain, switching the unlocking conditions from BTC UTXO to Cardano's eUTXO. This step allows asset holders to control assets originally on the BTC chain through the Cardano chain.
  • The role of CKB in Leap:
  • CKB acts as a sort of indexer and data availability (DA) layer. All RGB++ asset data is still stored on the CKB chain, with CKB serving as a third-party witness to handle Leap requests and ensure the security of cross-chain assets.
  • CKB provides security and trustworthiness: Compared to the multi-signature or MPC (multi-party computation) mechanisms commonly found in traditional cross-chain bridges, CKB's security and decentralization attributes are more reliable.

2.2.5 The Role of RGB++ in Stablecoin Payments

  • Issuance and circulation of stablecoins: Stablecoins can be issued on the BTC chain through RGB++, leveraging CKB for intelligent asset management.
  • Cross-chain asset management: The combination of RGB++ Layer and CKB ensures seamless operation of stablecoin payments across different UTXO chains.
  • Smart contract support: Provides complex payment conditions, time locks, and other functionalities for stablecoin payments, enhancing payment flexibility and security.
  • Bridge function: The RGB++ Layer acts as a bridge between BTC (and other UTXO chains) and CKB, expanding BTC's programmability and asset management capabilities, making BTC's stablecoin payment functions more diverse and flexible.

2.3 Fiber Network

2.3.1 Introduction to Fiber Network

  • Fiber Network is a Layer 2 extension solution on CKB similar to the BTC Lightning Network: It is specifically designed to enhance CKB's off-chain payment capabilities, allowing users to make fast, low-cost payments off-chain. It achieves off-chain transactions through payment channels, reducing the pressure on the main chain and improving transaction speed.
  • Characteristics of off-chain payments: Fiber Network enables rapid transfers off-chain through payment channels, reducing reliance on the CKB main chain and increasing transaction throughput.
  • Current status: As of September 2024, according to mempool data, over $300 million is currently deployed in the BTC Lightning Network, with approximately 12,000 nodes and nearly 50,000 payment channels built between them.
  • Sources:
  • https://mp.weixin.qq.com/s/RSgzJeGnOdkqi8BQoW6xqw
  • https://mp.weixin.qq.com/s/SFIsmjf2CDWJvSDbi5unmA
  • https://mp.weixin.qq.com/s/roWA-DlD0H-wlvmyaY9vgA
  • https://hackernoon.com/fiber-network-a-lightning-network-based-on-ckb

2.3.2 Technical Highlights

  • Off-chain payment channels (Fiber Channels): Fiber Network allows users to exchange assets directly off-chain by creating payment channels, submitting the final state to the CKB main chain for settlement only when the channel closes.
  • On-chain contracts (HTLC):
  • Similar to the BTC Lightning Network, Fiber Network currently also uses Hash Time Locked Contracts (HTLC) to ensure the security of off-chain transactions; if an off-chain transaction is not confirmed within the agreed time, assets can be automatically returned through HTLC.
  • PTLC: Fiber Network improves upon HTLC by avoiding the use of the same cryptographic value across the entire payment path, using PTLC to prevent privacy leakage of transaction associations.
  • Multi-hop routing:
  • Like the BTC Lightning Network, Fiber Network supports payment path jumps through multiple nodes, searching for payment paths based on the Dijkstra algorithm, thereby reducing routing costs and increasing the success rate of multi-hop payments.
  • Monitoring service - Watchtower Service:
  • Users can utilize a 24/7 monitoring service to monitor the status of payment channels, preventing malicious nodes from attempting double spending or cheating (preventing transaction participants from submitting expired Commitments on-chain). This service can automatically track transactions and alert users.

2.3.3 Differences Between Fiber Network and BTC Lightning Network

  • Multi-asset support:
  • BTC Lightning Network only supports off-chain payments for BTC, and may support other assets in the future through the Taproot Asset upgrade, but currently only natively supports BTC;
  • Fiber Network supports multiple assets, including CKB, BTC, RGB++ stablecoins, etc.
  • Transaction fees and speeds:
  • BTC Lightning Network incurs higher BTC fees when opening and closing channels due to its operation on the BTC chain, especially when BTC transaction fees rise, significantly increasing the cost of channel operations;
  • Fiber Network, relying on CKB, has higher TPS and lower transaction fees, making the costs of opening and closing channels lower and providing a better user experience.
  • Cross-chain interoperability:
  • BTC Lightning Network is primarily used for payments within the BTC network and does not yet support cross-chain payments with other UTXO chains.
  • Fiber Network supports the circulation of various assets, including: BTC native assets (including inscriptions, runes, etc.), CKB, and RGB++ native assets (including RUSD, etc.).
  • Cross-chain asset off-chain payments: With the help of RGB++ Layer, all UTXO chain assets can enter the Lightning Network.
  • Fiber Network and BTC Lightning Network can interconnect: Achieving cross-chain payments (only Fiber Network can initiate, BTC Lightning Network can receive), allowing users to use CKB or RGB++ assets to purchase assets on the BTC Lightning Network while ensuring the atomicity of cross-chain transactions (preventing situations where some assets succeed/ fail in cross-chain transactions).

2.3.4 The Role of Fiber Network in Stablecoin Payments

  • Fiber Network supports off-chain stablecoin transfers, ensuring the immediacy and low cost of payments.
  • Fiber Network enables users to conduct high-frequency trading off-chain by creating off-chain payment channels, reducing pressure on the main chain.
  • Fiber Network supports cross-chain atomic payments, allowing stablecoin payments to securely traverse multiple chains.

2.4 Stable++

2.4.1 Introduction to Stable++

  • A decentralized over-collateralized stablecoin protocol in the CKB ecosystem, allowing users to mint USD-pegged RUSD by collateralizing BTC or CKB.
  • RUSD is theoretically the first stablecoin issued directly on the Bitcoin network based on the RGB++ protocol, leveraging CKB's capabilities to provide a more localized and efficient solution (subject to questions).
  • Transaction fees: Users are charged fees for minting RUSD by collateralizing BTC/CKB and redeeming BTC/CKB by returning RUSD.
  • RUSD staking: Users can earn governance tokens STB by staking RUSD they lend out.
  • Governance token STB
  • Users can earn rewards by participating in collateral liquidation through staking STB.
  • Users can participate in fee sharing by staking STB.
  • Cross-chain interoperability: RUSD can achieve transfers between UTXO chain accounts through RGB++'s isomorphic binding and Leap functions.
  • Lower minimum collateralization ratio (MCR): Thanks to efficient liquidation, the risk of potential losses faced by the protocol and stability providers is reduced, thereby lowering the demand for collateral value.
  • Decentralization: Stable++ is a fully decentralized, independently operating protocol that requires no control or permission from any entity, allowing users to interact with the system freely and securely.

2.4.2 Liquidation Mechanism - Dual Insurance

  • Overview: The liquidation mechanism is a protective measure triggered when the value of collateral falls below a certain critical point (minimum collateralization ratio * borrowed RUSD), ensuring that the generated RUSD stablecoin is always sufficiently backed by collateral. The system will automatically liquidate users who are under-collateralized to maintain the overall stability of the system.
  • Stability Pool:
  • To address inefficiencies during widespread liquidations, Stable++ uses a stability pool to replace the auction method commonly used in most lending protocols for liquidation, eliminating the need to find liquidators in the market.
  • Automatic liquidation: The stability pool requires LPs (users) to pre-deposit RUSD as reserves. When liquidation occurs, RUSD equivalent to the bad debt in the stability pool will be directly burned, while the collateral will be directly allocated to LPs.
  • By automatically liquidating through the stability pool and directly distributing excess collateral, this mechanism improves the operational efficiency and stability of stablecoins during widespread liquidations compared to traditional auctions.
  • Reallocation
  • Overview: When the stability pool does not have enough reserves to cover bad debt liquidation, the bad debt and collateral will be allocated among borrowers through a sufficiency allocation mechanism.
  • Debt reallocation: When the liquidation pool cannot cover all bad debts, the remaining debt will be proportionally redistributed among all borrowers.
  • Collateral distribution: While all borrowers collectively absorb the bad debt, they will also receive a proportional allocation of excess collateral as a reward.
  • By having all borrowers collectively bear the bad debt, this mechanism ensures that there are no uncovered debts in the system, preventing the accumulation of systemic risks.

2.4.3 The Role of Stable++ in Stablecoin Payments

  • The Stable++ protocol generates the stablecoin RUSD, serving as the primary stablecoin used in payments.
  • Stable++ improves the traditional over-collateralization method through its innovative liquidation mechanism, ensuring the stability of RUSD's price.
  • With the help of RGB++'s isomorphic binding and Leap capabilities, RUSD becomes the first truly transferable stablecoin across any UTXO-supporting chain, further broadening the liquidity of stablecoins.

2.5 JoyID

2.5.1 What is JoyID

2.5.2 Main Features

  • No passwords or mnemonic phrases required: Access the wallet through biometrics, achieving keyless login.
  • Supports BTC and Fiber Network: Users can trade faster and more efficiently, helping to expand the application scenarios of CKB.
  • Multi-chain support: JoyID supports not only BTC and Nervos CKB but also ETH and a range of EVM chains.
  • Additional security through Passkey: Passkey generates the secp256k1 signatures required for blockchain transactions through secp256r1 signatures associated with hardware devices, as secp256r1 signatures are not exposed in transactions and are only generated through biometric information, adding extra security to the wallet.
  • Combination of security and usability
  • Security: Hardware wallet > Passkey wallet > Software non-custodial wallet > Custodial wallet
  • Usability: Passkey wallet > Custodial wallet > Software non-custodial wallet > Hardware wallet

2.5.3 The Role of JoyID in Stablecoin Payments

  • JoyID serves as the user interface, allowing users to make stablecoin payments on the CKB network, managing their RUSD assets and payment channels.
  • JoyID, through its excellent combination of capabilities (security, usability, multi-chain support), can further empower stablecoin payments and other transactions based on CKB.
  • Payment initiation and acceptance: Users can open payment channels through the JoyID wallet to make stablecoin payments.
  • Stablecoin issuance: RGB++ and Stable++ work together, with Stable++ generating RUSD through over-collateralizing BTC or CKB, then issuing it on-chain through RGB++.
  • Cross-chain transactions & circulation: RGB++ seamlessly connects the BTC chain (and other UTXO chains) with the CKB chain through isomorphic binding and Leap, allowing RUSD and other assets to perform cross-chain operations across multiple UTXO chains, expanding the range of asset circulation and ensuring data synchronization.
  • Transaction records and settlement: The combination of Fiber Network and CKB supports rapid processing of off-chain payments, with CKB serving as the L1 chain to ensure the final settlement of transactions, safeguarding the security of all transaction states and assets.
  • Foundation for complex transactions: CKB's virtual machine and Cell model provide an execution environment for smart contracts, supporting complex payment conditions and custom contract logic, while also ensuring the decentralization of the Stable++ protocol.
ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
banner
ChainCatcher Building the Web3 world with innovators