Author: Jimmie, 10K Ventures
1. Overview
CKB stablecoin payment is a decentralized stablecoin payment solution based on the CKB network. It allows users to generate and manage the US dollar-pegged stablecoin RUSD through the joint network of CKB and Bitcoin, leveraging Layer 2 extensions such as RGB++ and Fiber Network, to achieve 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 Nervos Network. Its main functions can be summarized as consensus & execution and data availability. It improves scalability through payment channels and RGB++ built on it.
It is based on the PoW consensus mechanism, similar to BTC, and uses an upgraded version of the BTC algorithm NC-MAX. This algorithm improves the efficiency and responsiveness of the network by speeding up transaction confirmation time and reducing the orphan block rate. Unlike BTC's fixed interval of one block every 10 minutes, CKB dynamically adjusts the block interval (approximately every four hours) based on network activity to optimize performance.
CKB uses the Eaglesong hash function, a hash function customized specifically for the Nervos Network, as an alternative to SHA-256, which provides the same security
CKB uses the Cell model as the core of its data structure, which is an improved version of BTC’s UTXO accounting model.
Through the dual script system, it allows more flexible data storage and verification, supports asset issuance and smart contract execution
Provides data storage and state management functions to ensure 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 it implements on-chain data storage and verification of smart contract scripts by introducing dual scripts.
Store any type of data or assets: In BTC's UTXO model, each transaction output can only contain simple amount information and ownership; while each Cell of CKB can store smart contract code) and trigger the execution of these scripts through external calls in transactions, which means that each Cell can independently execute the smart contract logic related to it, which is programmable
Separation of state and computation: Because Cell stores the code and state of smart contracts, each Cell is allowed to independently execute contract logic. Complex computational tasks can be executed on Layer 2 or off-chain, and the execution results are synchronized back to Layer 1 through transactions, ensuring network security and data consistency.
Parallel execution & packaged transactions: Through the Cell model, smart contracts in different Cells can be executed in parallel, and at the same time, the transaction results of different Cells can be packaged and updated on the chain. This method is more efficient and reduces transaction costs.
How the Cell model works:
Live Cell refers to a Cell that has not been spent yet and can still be used as input for the next transaction or status update.
When a Cell is spent, it becomes a Dead Cell and can no longer be used, but its history is retained on the chain to ensure traceability.
Lock script: used for identity authentication, similar to the signature mechanism of BTC, to prevent unauthorized users from accessing or modifying the data in the Cell. Users must provide the correct signature or multiple signatures to unlock and use the Cell.
Type script: defines the data verification logic of the Cell, which is used to set the rules for how to use or change the Cell in future transactions, and determines the legitimacy of transactions or states by executing smart contracts or rule verification.
Cell is composed of input and output: Similar to BTC's UTXO model, Cell performs transactions and status updates through input and output. Each Cell can be spent as an input of a transaction and generate new outputs to create new Cells.
Cell components: Each Cell contains Capacity, Updated Data, Lock Scripti, Type Script
Capacity: Capacity records the size of the Cell storage space and also represents the storage value of the CKByte token. The Cell created by the user needs to allocate a certain Capacity according to the amount of data to ensure that the on-chain storage space is effectively utilized.
Data: It is one of the core features of the Cell model. It can store any information from simple numbers to complex smart contract status, allowing diverse data to be stored on the blockchain.
Dual script system:
Live Cell & Dead Cell:
State leasing mechanism: Users need to pay CKByte tokens to lease storage space on the chain to ensure long-term data storage and prevent state bloat.
Sources:
2.1.3 Programmability & CKB-VM
The Cell model is the foundation of CKB programmability: it supports storing the status of smart contracts and executing scripts in each Cell, making the execution of contracts and the management of assets closely integrated.
Through the Turing-complete RISC-V virtual machine (CKB-VM), developers can execute custom smart contracts on the 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 wide compatibility makes CKB-VM different from other blockchain virtual machines that are usually limited to specific languages, and open to a wider developer community. The CKB network also supports SDKs for mainstream languages such as JavaScript, Rust, Go, and Java, making it easier for developers to develop using familiar tools.
Compatibility and scalability: CKB-VM is designed to ensure compatibility with BTC’s UTXO model and other blockchains, while supporting highly scalable smart contracts and complex applications.
Sources:
https://medium.com/nervosnetwork/an-introduction-to-ckb-vm-9d95678a7757
2.1.4 PoW consensus mechanism
CKB uses a PoW consensus mechanism similar to BTC to ensure the security and decentralization of the network. Similar to BTC, miners pack blocks by competing to calculate hash values, thereby ensuring the network's immutability and anti-censorship.
NC-MAX algorithm: Compared with BTC, CKB introduced an improved NC-MAX algorithm. This improvement allows higher throughput and optimizes block packaging efficiency, reduces the orphan block rate, and increases 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 Eaglesong hash function provides performance and security advantages to the Nervos CKB network through ASIC neutrality, efficiency, security and network fairness, ensuring decentralization while improving mining efficiency and network scalability.
Sources:
https://docs.nervos.org/docs/tech-explanation/consensus#nc-max-consensus-algorithm
2.1.5 Multi-layered security architecture
CKB adopts a multi-layered security architecture: Layer 1 focuses on the final settlement of data and the secure preservation of status, while Layer 2 is used to expand transaction processing capabilities.
The separated architecture ensures the security of the main chain (Layer 1): reduces the load when processing transactions and improves the stability of the overall network
2.1.6 Connection with BTC and legitimacy
Cross-chain interoperability of the UTXO model:
CKB's Cell model is an extension of the BTC UTXO model. This similarity allows assets on the BTC UTXO model to be cross-chain operated on CKB through cross-chain bridging tools such as Force Bridge. BTC users can map their assets to the CKB network and use the flexibility of the CKB network for storage, smart contract operations, and decentralized finance (DeFi) applications.
Since Cell and BTC UTXO are similar in structure, and CKB is compatible with BTC signature algorithm, users can use BTC wallet to manipulate CKB chain assets. The same is true for other UTXO public chains.
Legitimacy: CKB maintains consistency with BTC by adopting NC-Max (Nakamoto Consensus Max), which is an improved version of Nakamoto Consensus, providing better security and performance.
Community support: The Nervos community is composed of many blockchain technology enthusiasts, developers and miners, and has received support from some BTC communities. The legitimacy of Nervos lies in that it inherits the decentralized thinking of BTC and meets a wider range of needs through expanded functions.
material:
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 CKB’s role in stablecoin payments
Storage and management of stablecoin balances: CKB's Cell model is the basis for stablecoin storage. The user's stablecoin balances such as RUSD are stored in the Cell on the chain. Each Cell contains complete balance information, ensuring the security and traceability of assets.
Record transaction status: CKB supports recording every state change of transactions on the chain, and all payment processes can be transparently recorded and tracked through the Cell model. This mechanism is crucial in stablecoin payments, ensuring the security and verifiability of transactions.
Execution of smart contracts: Complex operations such as conditional payment and locking in the stablecoin payment process can be implemented through smart contracts supported by CKB-VM.
2.2 RGB++
2.2.1 What is RGB++
A decentralized asset issuance and smart contract protocol suitable for Bitcoin UTXO model and other UTXO public chains
The RGB++ protocol is developed from the RGB protocol, and inherits the idea of creating a transaction on the chain and off the chain and binding them separately. The difference is that RGB uses client verification to move more data that cannot be stored and smart contracts that cannot be implemented on the BTC network to the off-chain, and creates corresponding transactions to bind them to the chain, while RGB++ moves these data that cannot be stored and smart contracts that cannot be implemented to CKB, making CKB the smart contract settlement layer of BTC.
material:
https://hackernoon.com/utxo-stack-the-complete-edition-of-the-rgb-protocol-charting-bitcoins-course
https://www.nervos.org/knowledge-base/Understanding_Bitcoin_layer2_%28explainCKBot%29
https://medium.com/@utxostack/the-magic-of-rgb-bridgeless-cross-chain-leap-70ed82bed3ab
2.2.2 Basic functions
Through RGB++, CKB is used as the shadow chain of BTC: as a supplementary chain of BTC, it undertakes complex logic and smart contract operations in Turing machines that BTC cannot handle natively.
Interacting with the BTC network
Transactions occur: In the BTC network, users complete transactions through the conventional UTXO model, while the part involving smart contract execution uses RGB++ to bind the contract status and data to CKB
Verification logic: Transaction records on the BTC network will be synchronized with the contract status stored on CKB through RGB++, and the legitimacy of the transaction will be ensured through specific verification logic. Whenever a transaction occurs on the network, RGB++ will trigger the contract execution on CKB, and check whether the transaction complies with the predetermined rules through the on-chain contract logic, such as whether the balance is sufficient, whether the signature is valid, whether the contract conditions are met, etc.
RGB++ uses the client-side validation model to ensure the privacy and integrity of off-chain data. Only when the off-chain verification is passed will the data be submitted to CKB for final settlement.
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 life cycle of these assets (including not only the issuance and circulation of assets, but also more complex operations such as time locks, conditional payments, etc.)
RGB++ combines the high security of BTC with the programmability of CKB
2.2.3 Isomorphic Binding
Cross-chain synchronization of assets and status: Isomorphic binding means that assets and status are synchronized 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++ will map the corresponding contract status or asset changes on CKB.
Extended UTXO: In isomorphic binding, each UTXO on the BTC chain will have a corresponding Cell (UTXO container) on CKB, and record the corresponding asset status and smart contract conditions
Asset Binding: When a user holds a certain RGB++ asset on the BTC chain, the Cell on CKB will store the corresponding asset status. The two chains are bound together to ensure the consistency of these asset information.
Transaction synchronization: When an RGB++ token transaction occurs, the isomorphic binding mechanism will generate a Commitment on the BTC network. On the CKB chain, the corresponding Cell will be consumed, and new Cells will be generated to distribute assets.
Advantages of Homogeneous Binding - Empowering BTCFi
Smart contract support: BTC cannot natively support Turing-complete smart contracts. Through isomorphic binding, CKB can serve as the execution layer of smart contracts to manage complex transaction conditions of BTC assets, such as time locks, conditional payments, etc.
Flexibility in asset management: Isomorphic binding allows the management of assets circulating in the BTC network on CKB. Users can perform complex financial operations through CKB’s flexible programming capabilities without changing the underlying protocol of BTC.
2.2.4 Leap
RGB++ Layer upgrade proposes: Extend the binding relationship between CKB and BTC to all UTXO chains, and realize cross-chain asset transfer through "binding exchange"
Bridgeless cross-chain between BTC and other UTXO chains: Its core purpose is to enable the seamless transfer of RGB++ assets on the BTC chain to other UTXO chains. It supports the management and transfer of assets on multiple blockchains by switching the UTXO bound to the assets.
Bridgeless technology: Leap uses isomorphic binding technology and switches UTXO on different chains without relying on the traditional Lock-Mint cross-chain bridge to achieve cross-chain transfer of assets
Operation process: For example, users can control RGB++ assets originally on the BTC chain through the Cardano chain, and split and transfer assets on the Cardano chain.
Release Commitment: First, the user needs to release a Commitment on the BTC chain, stating that the assets bound to the BTC UTXO will be unbound.
Cardano chain binding: Next, issue a new Commitment on the Cardano chain to bind the RGB++ asset to Cardano’s eUTXO
Modify the locking script: Then, modify the locking script of the RGB++ asset on the CKB chain and switch the unlocking condition from BTC UTXO to eUTXO on the Cardano chain. This step allows asset holders to control the assets originally on the BTC chain through the Cardano chain.
The role of CKB in Leap:
CKB plays a role similar to an indexer and data availability (DA) layer. All RGB++ asset data is still stored on the CKB chain. CKB acts as a third-party witness to process Leap requests and ensure the security of cross-chain assets.
CKB provides security and credibility: Compared with the multi-signature or MPC (multi-party computation) mechanism commonly used in traditional cross-chain bridges, CKB's security and decentralization properties are more reliable
2.2.5 The role of RGB++ in stablecoin payments
Issuance and circulation of stablecoins: Issue stablecoins on the BTC chain through RGB++, and use CKB to achieve intelligent management of assets.
Cross-chain asset management: Through the combination of RGB++ Layer and CKB, stablecoin payments can be seamlessly operated on different UTXO chains.
Smart contract support: Provide complex payment conditions, time locks and other functions for stablecoin payments to improve payment flexibility and security
Bridge function: 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 function 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 BTC Lightning Network: it is specially designed to improve CKB's off-chain payment capabilities, allowing users to make fast and low-cost payments off-chain. Off-chain transactions are realized through payment channels, reducing the pressure on the main chain and increasing transaction speed.
Features of off-chain payment: Fiber Network realizes fast off-chain transfer through payment channels, reduces dependence on the CKB main chain, and improves transaction throughput
Current situation: As of September 2024, according to mempool data, the current BTC lightning network has more than 300 million US dollars in funds, the number of nodes is about 12,000, and nearly 50,000 payment channels have been built between them.
material:
https://hackernoon.com/fiber-network-a-lightning-network-based-on-ckb
2.3.2 Technical points
Fiber Channels: Fiber Network allows users to exchange assets directly off-chain by creating payment channels, and the final state is not submitted to the CKB main chain for settlement until the channel is closed.
On-chain contract (HTLC):
Similar to the BTC Lightning Network, the Fiber Network now also uses hash time lock contracts (HTLC) to ensure the security of off-chain transactions; if the off-chain transaction is not confirmed within the agreed time, the assets can be automatically returned through HTLC
PTLC: Fiber Network improves on HTLC to avoid using the same encryption value for the entire payment path graph. PTLC will be used to prevent privacy leakage of transaction correlation.
Multi-Hop Routing:
Fiber Network, like BTC Lightning Network, supports payment path jumps through multiple nodes and searches for payment paths based on the Dijkstra algorithm, thereby reducing routing costs and increasing the success rate of multi-hop path payments.
Monitoring Service-Watchtower Service:
Users can use the 24/7 monitoring service to monitor the status of payment channels to prevent malicious nodes from attempting double spend or cheating (preventing transaction participants from submitting expired commits to the chain). The service can automatically track transactions and issue alarms.
2.3.3 Differences between Fiber Network and BTC Lightning Network
Multi-asset support:
The BTC Lightning Network only supports BTC off-chain payments. In the future, it may support other assets through Taproot Asset upgrades, but currently it can only natively support BTC.
Fiber Network supports a variety of assets, including CKB, BTC, RGB++ stablecoins, etc.
Fees and transaction speed:
Since the BTC Lightning Network runs on the BTC chain, it needs to pay higher BTC fees when opening and closing channels. Especially when BTC transaction fees rise, the channel operation costs increase significantly;
Fiber Network has higher TPS and lower transaction fees due to its reliance on CKB, which makes the operation cost of opening and closing channels lower and provides a better user experience.
Cross-chain interoperability:
The BTC Lightning Network is mainly used for payments within the BTC network and does not yet support cross-chain payments on other UTXO chains.
Fiber Network supports the circulation of multiple assets including: BTC native assets (including inscriptions, runes, etc.), CKB, RGB++ native assets (including RUSD, etc.)
Cross-chain asset off-chain payment: With the help of RGB++ Layer, all UTXO chain assets can enter the Lightning Network
Fiber Network and BTC Lightning Network can be interconnected: cross-chain payment is realized (only Fiber Network can send, BTC Lightning Network can receive), users can use CKB or RGB++ assets to purchase assets on BTC Lightning Network through Fiber Network, and ensure the atomicity of cross-chain transactions (there will be no situation where some assets succeed/fail to cross-chain)
2.3.4 The role of Fiber Network in stablecoin payments
Fiber Network is used to support off-chain stablecoin transfers, ensuring instant and low-cost payments
Fiber Network creates off-chain payment channels, allowing users to conduct high-frequency transactions off-chain, reducing the pressure on the main chain.
Fiber Network supports cross-chain atomic payments, allowing stablecoin payments to safely cross multiple chains
2.4 Stable++
2.4.1 Introduction to Stable++
A decentralized over-collateralized stablecoin protocol for the CKB ecosystem that allows users to mint RUSD pegged to the US dollar by pledging 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 (questionable)
Fees: Users will be charged a fee for pledging BTC/CKB to mint RUSD and returning RUSD to redeem BTC/CKB.
RUSD staking: Users can obtain governance tokens STB by staking borrowed RUSD
Governance Token STB
Users can obtain benefits by staking STB and participating in the liquidation of collateral.
Users can participate in the fee sharing by staking STB
Cross-chain interoperability: RUSD can be transferred between UTXO chain accounts through RGB++’s isomorphic binding and Leap function
Lower minimum collateral ratio (MCR): Thanks to efficient liquidation, the risk of potential losses faced by protocols and stability providers is reduced, thereby reducing the need for collateral value
Decentralization: Stable++ is a fully decentralized, independently operated protocol that does not require control or permission from any entity. Users can interact with the system freely and securely.
material:
https://jackylhh.notion.site/Stable-RGB-Layer-9b2c3a385d5d4ce89f176d2b9c1701e4
https://medium.com/@NervosCN/stable-%E6%8E%A0%E5%BD%B1-%E6%89%AD%E8%BD%AC%E6%BD%AE%E6%B5%81%E7%9A%84%E5%8D%8F%E8%AE%AE-de7eadee5036
2.4.2 Liquidation Mechanism - Double Insurance
Overview: The liquidation mechanism is a protective measure triggered when the value of the collateral drops to a certain critical point (minimum pledge ratio * loaned RUSD), ensuring that the generated RUSD stablecoin always has sufficient collateral support. The system will automatically liquidate those users with insufficient collateral to maintain the stability of the overall system.
Stability Pool:
To solve the problem of inefficiency when large-scale liquidation occurs, Stable++ uses a stable pool to replace the auction method commonly used in most lending protocols for liquidation, eliminating the need to look for liquidators in the market.
Automatic liquidation: The stable pool requires LPs (users) to deposit RUSD in advance as a reserve. When liquidation occurs, the RUSD in the stable pool equal to the bad debt will be directly destroyed, and the collateral will be directly allocated to LPs.
Through the ability of automatic liquidation in the stable pool, the traditional auction is replaced by direct allocation of excess collateral, which improves the operating efficiency and stability of stablecoins in the event of large-scale liquidation.
Redistribution
Overview: When the stability pool does not have enough reserves to complete the bad debt liquidation, the bad debt and collateral will be distributed among the borrowers through the full allocation mechanism
Debt redistribution: When the liquidation pool cannot cover all bad debts, the remaining debt will be redistributed proportionally among all borrowers
Collateral distribution: All borrowers will share the bad debts and will also receive a proportional allocation of excess collateral rewards.
By making all borrowers share the burden of bad debts, this mechanism ensures that there is no uncovered debt in the system and avoids the accumulation of systemic risks.
2.4.3 The role of Stable++ in stablecoin payments
The Stable++ protocol generates the stablecoin RUSD as the main stablecoin used in payments
Stable++ improves the traditional over-collateralization method through an innovative liquidation mechanism, ensuring the stability of the RUSD price.
Stable++ leverages RBG++’s isomorphic binding and Leap capabilities to make RUSD the first stablecoin that can circulate freely on any chain that supports UTXO, further broadening the liquidity of stablecoins.
2.5 JoyID
2.5.1 What is JoyID
JoyID Passkey Wallet is an encrypted wallet combined with Passkey key management
In the Nervos ecosystem, JoyID is designed as a cross-chain, decentralized identity authentication and management tool that allows users to securely store and use cryptocurrencies and other decentralized applications.
material:
https://nervina.notion.site/JoyID-8645e910ef104962b01bd4835a8ea7dc
https://x.com/joy_protocol/status/1836299130345525533
2.5.2 Main functions
No password or seed phrase required: Access your wallet with biometrics, no private key required
Support for BTC and Fiber Network: Users can trade faster and more efficiently, and can help expand CKB’s application scenarios
Multi-chain support: Not only BTC and Nervos CKB, JoyID also supports ETH and a series of EVM chains
Get extra security through Passkey: Passkey generates the secp256k1 signature required for blockchain transactions through the secp256r1 signature associated with the hardware device. Because the secp256r1 signature is not exposed in the transaction and is only generated through biometric information, it adds extra security to the wallet
Combination of safety and ease of use
Security: Hardware wallet > Passkey wallet > Software non-custodial wallet > Custodial wallet
Ease of use: Passkey wallet > custodial wallet > software non-custodial wallet > hardware wallet
2.5.3 JoyID’s role in stablecoin payments
JoyID serves as a user interface, allowing users to make stablecoin payments in the CKB network and manage their RUSD assets and payment channels
JoyID can further enable CKB-based stablecoin payments and other transactions through its excellent combination of capabilities (security, ease of use, and multi-training support).
3. Payment Link
Payment initiation and acceptance: Users can open payment channels through the JoyID wallet and make stable currency payments
Stablecoin issuance: RGB++ and Stable++ work together. Stable++ generates RUSD by over-collateralizing BTC or CKB, and then issues it on the chain through RGB++
Cross-chain transactions & circulation: RGB++ seamlessly connects the BTC chain (and other UTXO chains) and the CKB chain through isomorphic binding and Leap, allowing RUSD and other assets to perform cross-chain operations on multiple UTXO chains, expanding the scope of asset circulation and ensuring data synchronization.
Transaction records and settlement: The combination of Fiber Network and CKB supports the rapid processing of off-chain payments, and CKB as an L1 chain guarantees the final settlement of transactions and ensures the security of all transaction status and assets.
The basis for complex transactions: CKB's virtual machine and Cell model provide an execution environment for smart contracts, support complex payment conditions and custom contract logic, and also ensure the decentralization of the Stable++ protocol