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 a 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, with its main functions summarized as Consensus & Execution and Data Availability, enhancing scalability through payment channels and RGB++ built on top of it.
It is based on a PoW consensus mechanism, similar to BTC, and employs an upgraded BTC algorithm called NC-MAX, which improves network efficiency and responsiveness by speeding up 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 customized for the Nervos Network, providing the same level of security as SHA-256.
CKB adopts the Cell model as its core 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 and Its 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; whereas 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, complex computational tasks can be executed independently by each Cell 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 and transaction bundling: Through the Cell model, smart contracts in different Cells can achieve parallel execution, while the transaction results of different Cells can be bundled and updated on-chain, making this method 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 storage space of the Cell and represents the storage value of CKB tokens. Users creating Cells need to allocate a certain Capacity based on the amount of data to ensure effective utilization of on-chain storage space.
- Data: This is one of the core features of the Cell model, allowing for the storage of diverse data, from simple numbers to complex smart contract states, enabling the storage of varied data on the blockchain.
- Dual-script system: The Lock Script is 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; the 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 smart contract execution or rule validation.
- 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; when a Cell is spent, it becomes a Dead Cell and can no longer be used, but its historical record remains on-chain to ensure traceability.
- State leasing mechanism: Users need to pay CKB tokens to lease storage space on the chain, ensuring long-term data storage while preventing state bloat.
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.
2.1.4 PoW Consensus Mechanism#
CKB adopts a PoW consensus mechanism similar to BTC, ensuring the security and decentralization of the network. 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 an improved NC-MAX algorithm. This improvement allows for higher throughput and optimizes block packaging efficiency, reducing orphan block rates and enhancing transaction confirmation speed, 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.
2.1.5 Multi-layer Security Architecture#
CKB employs 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 and improving 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 the BTC UTXO model. BTC users can map their assets to the CKB network, utilizing 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 signature algorithms, users can manipulate CKB on-chain assets using BTC wallets, similarly applicable to other UTXO public chains.
Orthodoxy: CKB maintains conceptual consistency with BTC by adopting NC-Max (Nakamoto Consensus Max), which is an improved version of the 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 expanding functionality to meet broader needs.
2.1.7 CKB's Role in Stablecoin Payments#
Storage and management of stablecoin balances: CKB's Cell model serves as the foundation for stablecoin storage, with users' stablecoin balances like RUSD stored in Cells on the 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 for stablecoin payments, ensuring transaction security and verifiability.
Execution of smart contracts: Complex operations such as conditional payments and locks during stablecoin payment processes can be realized through smart contracts supported by CKB-VM.
2.2 RGB++#
2.2.1 What is RGB++#
RGB++ is a decentralized asset issuance and smart contract protocol suitable for the Bitcoin UTXO model and other UTXO public chains.
The RGB++ protocol inherits the idea of creating a transaction on-chain and off-chain and binding them from the RGB protocol. The difference is that RGB utilizes client-side validation to move more data that cannot be stored on the BTC network and smart contracts that cannot be realized off-chain, creating corresponding transactions bound to the chain, while RGB++ moves this data and smart contracts to CKB, making CKB the smart contract settlement layer for BTC.
2.2.2 Basic Functions#
Using RGB++, CKB acts as a shadow chain for BTC: As a supplementary chain to BTC, it handles 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 are bound to CKB through RGB++.
- Validation Logic: Transaction records on the BTC network will synchronize with the contract states stored on CKB through RGB++, ensuring transaction legality through specific validation 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 met.
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#
Asset & State Cross-chain Synchronization: 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 will have 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 this asset information between the two chains through isomorphic binding.
Transaction Synchronization: When an RGB++ token transaction occurs, the isomorphic binding mechanism generates a Commitment on the BTC network, consuming the corresponding Cell on the CKB chain, while a new Cell is generated to allocate the asset.
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: Extends the binding relationship between CKB and BTC to all UTXO chains, achieving cross-chain asset transfer through "re-binding."
Bridge-less cross-chain between BTC and other UTXO chains: Its core purpose is to enable RGB++ assets on the BTC chain to seamlessly transfer to other UTXO chains by switching the UTXO to which the asset is bound, 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, a user can control RGB++ assets originally on the BTC chain through the Cardano chain and perform asset splitting and transfer on the Cardano chain.
- Publish Commitment: First, the user needs to publish a Commitment on the BTC chain, declaring the intention to unbind the asset bound to the BTC UTXO.
- Cardano Chain Binding: Next, a new Commitment is published on the Cardano chain, binding the RGB++ asset to Cardano's eUTXO.
- Modify 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 the asset holder to control the asset originally on the BTC chain through the Cardano chain.
CKB's Role in Leap:
- CKB acts as an 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 RGB++'s Role in Stablecoin Payments#
Issuance and circulation of stablecoins: Stablecoins are issued on the BTC chain through RGB++, leveraging CKB for smart asset management.
Cross-chain asset management: The combination of RGB++ Layer and CKB ensures seamless stablecoin payments across different UTXO chains.
Smart contract support: Provides complex payment conditions, time locks, and other functions for stablecoin payments, enhancing payment flexibility and security.
Bridge Role: 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 reduces the pressure on the main chain and improves transaction speed through payment channels.
Characteristics of off-chain payments: Fiber Network achieves rapid transfers off-chain through payment channels, reducing dependence on the CKB main chain and enhancing transaction throughput.
Current Status: As of September 2024, according to mempool data, over $300 million is currently allocated in the BTC Lightning Network, with approximately 12,000 nodes building nearly 50,000 payment channels. The Fiber Network based on Nervos CKB has already launched its testnet.
2.3.2 Technical Highlights#
Off-chain payment channels (Fiber Channels): Fiber Network allows users to directly exchange assets off-chain by creating payment channels, submitting the final state to the CKB main chain for settlement only when the channel is closed.
On-chain contracts (HTLC):
- Similar to the BTC Lightning Network, Fiber Network now 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 to avoid using the same cryptographic value across the entire payment path, utilizing 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, using the Dijkstra algorithm to search for payment paths, thereby reducing routing costs and increasing the success rate of multi-hop payments.
Monitoring Service - Watchtower Service: Users can utilize 24/7 monitoring services to track the status of payment channels, preventing malicious nodes from attempting double spending or cheating (preventing transaction participants from submitting expired commits on-chain), with this service automatically tracking transactions and alerting users.
2.3.3 Differences Between Fiber Network and BTC Lightning Network#
Multi-asset support:
- BTC Lightning Network previously only supported off-chain payments in BTC, but now supports other assets through the Taproot Asset upgrade.
- Fiber Network supports multiple assets, including CKB, BTC, RGB++ stablecoins, etc.
Transaction Fees and Speed:
- BTC Lightning Network incurs higher BTC fees when opening and closing channels due to operating on the BTC chain, especially when BTC transaction fees rise, significantly increasing channel operation costs.
- 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: native BTC 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, assets from all UTXO chains 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 (avoiding situations where some assets succeed/fail in cross-chain transfers).
2.3.4 Fiber Network's Role in Stablecoin Payments#
Fiber Network supports off-chain stablecoin transfers, ensuring the immediacy and low cost of payments.
Fiber Network allows users to conduct high-frequency trading off-chain by creating payment channels, reducing pressure on the main chain.
Fiber Network supports cross-chain atomic payments, enabling stablecoin payments to safely traverse multiple chains.
2.4 Stable++#
2.4.1 Introduction to Stable++#
Stable++ is a decentralized over-collateralized stablecoin protocol in the CKB ecosystem, allowing users to mint RUSD pegged to the US dollar by collateralizing BTC or CKB.
RUSD is theoretically the first stablecoin issued directly on the Bitcoin network based on the RGB++ protocol, utilizing CKB's capabilities to provide a more localized and efficient solution.
Fees: Users are charged fees for minting RUSD by collateralizing BTC/CKB and for redeeming BTC/CKB when returning RUSD.
RUSD Staking: Users can earn governance tokens STB by staking RUSD that they lend out.
Governance Token STB
- Users can earn profits 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 functionality.
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 - Double Insurance#
Overview: The liquidation mechanism is a protective measure triggered when the value of collateral falls below a certain critical point (minimum collateralization ratio for borrowing 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 the inefficiencies that occur during large-scale 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, an amount of RUSD equivalent to the bad debt in the stability pool will be directly destroyed, while the collateral will be directly allocated to LPs.
- By automatically liquidating through the stability pool, the ability to directly allocate excess collateral replaces traditional auctions, improving the operational efficiency and stability of stablecoins during large-scale liquidations.
Redistribution
- Overview: When the stability pool does not have enough reserves to cover bad debt liquidation, the bad debt and collateral will be redistributed among borrowers through a sufficiency allocation mechanism.
- Debt Redistribution: When the liquidation pool cannot cover all bad debts, the remaining debt will be redistributed among all borrowers proportionally.
- 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, avoiding the accumulation of systemic risks.
2.4.3 Stable++'s Role in Stablecoin Payments#
The Stable++ protocol generates the stablecoin RUSD, which is the primary stablecoin used in payments.
Stable++ improves the traditional over-collateralization method through its innovative liquidation mechanism, ensuring the stability of the RUSD price.
With the help of RGB++'s isomorphic binding and Leap capabilities, RUSD becomes the first truly freely circulating stablecoin across any UTXO-supporting chain, further broadening the liquidity of stablecoins.
2.5 JoyID#
2.5.1 What is JoyID#
The JoyID Passkey wallet is a cryptocurrency wallet that combines Passkey key management.
In the Nervos ecosystem, JoyID is designed as a cross-chain, decentralized identity authentication and management tool, allowing users to securely store and use cryptocurrencies and other decentralized applications.
2.5.2 Main Features#
- No passwords or mnemonic phrases required: Access the wallet through biometrics, enabling keyless login.
- Supports BTC and Fiber Network: Users can trade faster and more efficiently, helping to expand CKB's application scenarios.
- 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 generated only through biometric information, adding an extra layer of 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 JoyID's Role 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.
With its excellent combination of capabilities (security, usability, multi-chain support), JoyID can further empower stablecoin payments and other transactions based on CKB.
3. Payment Link#
- 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, and then issuing it on-chain through RGB++.
- Cross-chain Transactions and 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 operate cross-chain across multiple UTXO chains, expanding the asset circulation range and ensuring data synchronization.
- Transaction Records and Settlement: The combination of Fiber Network and CKB supports the rapid processing of off-chain payments, with CKB as the L1 chain ensuring the final settlement of transactions, securing 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 ensuring the decentralization of the Stable++ protocol.
References:
-
Messari Research Report: In-depth Analysis of Nervos Network (CKB)
-
System Interpretation of Fiber: A Grand Experiment of Bridging the Lightning Network to CKB
-
In-depth Analysis of the Evolution from RGB to RGB++ to RGB++ Layer: What Happened?
-
A Quick Guide to RGB and RGB++ Protocol Design: A Layman's Manual
-
Interpreting the Four Major Features of RGB++ Layer: The Hub of BTCFi and the UTXO World
-
Interpreting Stable++: The First Stablecoin Protocol on RGB++ Layer Officially Launches
-
UTXO Stack: The Complete Edition of the RGB++ Protocol Charting Bitcoin's Course
-
https://nervina.notion.site/JoyID-8645e910ef104962b01bd4835a8ea7dc
-
https://docs.nervos.org/docs/tech-explanation/cell-model#first-class-assets
-
https://docs.nervos.org/docs/tech-explanation/consensus#nc-max-consensus-algorithm