
Implementation of CKB Stablecoin Payment
TechFlow Selected TechFlow Selected

Implementation of CKB Stablecoin Payment
CKB is the Layer 1 blockchain of Nervos Network, whose main functions can be summarized as consensus and execution, as well as data availability.
Author: Jimmie, 10K Ventures
1. Overview
-
CKB stablecoin payment is a decentralized stablecoin payment solution based on the CKB network, enabling users to generate and manage USD-pegged stablecoin RUSD via the combined CKB and Bitcoin network, leveraging Layer 2 extensions such as RGB++ and Fiber Network for fast, low-cost, and secure cross-chain stablecoin payments.
2. Core Components Introduction
2.1 CKB (Common Knowledge Base)
2.1.1 What is CKB?
-
CKB is the Layer 1 blockchain of Nervos Network, with primary functions summarized as Consensus & Execution and Data Availability, enhancing scalability through payment channels and RGB++ built atop it.
-
It uses a PoW consensus mechanism similar to BTC, adopting an upgraded 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 10-minute block interval, CKB dynamically adjusts its block interval (approximately every four hours) based on network activity to optimize performance.
-
CKB employs the Eaglesong hash function, a custom-designed hash function tailored for the Nervos Network as a SHA-256 alternative, offering equivalent security.
-
CKB adopts the Cell model as the core of its data structure—an improved version of BTC's UTXO accounting model.
-
The dual-script system allows more flexible data storage and validation, supporting asset issuance and smart contract execution.
-
Provides data storage and state management capabilities, ensuring long-term availability of all on-chain assets and data.
-
2.1.2 Cell Model
-
Cell Model & Features:
-
The Cell model resembles BTC's UTXO model but enables on-chain data storage and verification of smart contract scripts through a dual-script system.
-
Stores arbitrary types of data or assets: 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 script execution via external calls during transactions. This means each Cell can independently execute associated smart contract logic, making it programmable.
-
Separation of State and Computation: Since Cells store smart contract code and state, complex computational tasks can be executed on Layer 2 or off-chain, with results synchronized back to Layer 1 via transactions, ensuring network security and data consistency.
-
Parallel Execution & Transaction Batching: The Cell model allows parallel execution of smart contracts in different Cells, and transaction outcomes from multiple Cells can be batch-updated on-chain, improving computational efficiency and lowering transaction fees.
-

-
How the Cell Model Works:

-
Live Cell refers to a currently unspent Cell that can still be used as input for subsequent transactions or state updates.
-
Once a Cell is spent, it becomes a Dead Cell and cannot be reused, though its history remains on-chain for traceability.
-
Lock Script: Used for identity verification, similar to BTC's signature mechanism, preventing unauthorized access or modification of data within the Cell. Users must provide correct signatures or multi-signatures to unlock and use the Cell.
-
Type Script: Defines the data validation logic of the Cell, setting rules for how the Cell can be used or modified in future transactions. It determines the validity of transactions or states by executing smart contracts or rule checks.
-
A Cell consists of inputs and outputs: Similar to BTC's UTXO model, Cells perform transactions and state updates through inputs and outputs. Each Cell can be spent as transaction input and generate new outputs, creating new Cells.
-
Components of a Cell: Each Cell contains Capacity, Updated Data, Lock Script, and Type Script.
-
Capacity: Records the size of the Cell's storage space and represents the storage value of CKByte tokens. Users must allocate sufficient Capacity based on data volume when creating a Cell to ensure efficient utilization of on-chain storage space.
-
Data: One of the key features of the Cell model, capable of storing any information—from simple numbers to complex smart contract states—enabling diverse data storage on the blockchain.
-
Dual-Script System:
-
Live Cell & Dead Cell:
-
State Rent Mechanism: Users must pay CKByte tokens to rent on-chain storage space, ensuring long-term data storage while preventing state bloat.
-
Sources:
2.1.3 Programmability & CKB-VM
-
The Cell model forms the foundation of CKB's programmability: It supports storing smart contract states and execution scripts in each Cell, tightly integrating contract execution with 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 greater freedom in writing contracts, allowing CKB to support complex contract logic.
-
CKB-VM supports multiple languages: Including popular ones like C and Rust. This broad compatibility distinguishes CKB-VM from other blockchain VMs typically limited to specific languages, opening access to a wider developer community. The CKB network also provides SDKs for mainstream languages such as JavaScript, Rust, Go, and Java, facilitating development 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 adopts a PoW consensus mechanism similar to BTC, ensuring network security and decentralization. Like BTC, miners compete to compute hash values to package blocks, ensuring immutability and censorship resistance.
-
NC-MAX Algorithm: Compared to BTC, CKB introduces the improved NC-MAX algorithm, which enables higher throughput, optimizes block packaging efficiency, reduces orphan block rates, and accelerates transaction confirmation—making it suitable for large-scale applications such as asset storage and payment settlement.
-
Eaglesong Hash Function: The custom design of the Eaglesong hash function offers advantages in ASIC neutrality, efficiency, security, and network fairness, providing performance and security benefits for the Nervos CKB network while maintaining decentralization and enhancing mining efficiency and 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 final settlement and secure state preservation, while Layer 2 extends transaction processing capacity.
-
This separation ensures mainchain (Layer 1) security by reducing transaction load and improving overall network stability.
2.1.6 Relationship with BTC and Orthodoxy
-
Cross-Chain Interoperability of UTXO Models:
-
The CKB Cell model is an extension of BTC's UTXO model. This similarity allows assets on BTC's UTXO model to perform cross-chain operations on CKB via tools like Force Bridge. BTC users can map their assets onto the CKB network, leveraging CKB's flexibility for storage, smart contract operations, and decentralized finance (DeFi) applications.
-
Due to structural similarities between Cells and BTC UTXOs, and CKB’s compatibility with BTC signature algorithms, users can operate CKB chain assets using BTC wallets. The same applies to other UTXO public chains.
-
-
Orthodoxy: CKB maintains conceptual consistency with BTC by adopting NC-Max (Nakamoto Consensus Max), an improved version of Nakamoto Consensus, offering better security and performance.
-
Community Support: The Nervos community comprises numerous blockchain technology enthusiasts, developers, and miners, receiving partial support from the BTC community. Its orthodoxy lies in inheriting BTC's decentralized philosophy while expanding functionality to meet broader needs.
-
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 CKB’s Role in Stablecoin Payments
-
Storing and Managing Stablecoin Balances: The CKB Cell model serves as the foundation for stablecoin storage, with user balances of stablecoins like RUSD stored in Cells on-chain. Each Cell contains complete balance information, ensuring asset security and traceability.
-
Recording Transaction States: CKB supports transparent recording and tracking of every state change in transactions. This mechanism is crucial for stablecoin payments, ensuring transaction security and verifiability.
-
Smart Contract Execution: Complex operations such as conditional payments and locking in stablecoin payments 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 applicable to Bitcoin UTXO models and other UTXO public chains.
-
Developed from the RGB protocol, RGB++ inherits the idea of creating separate on-chain and off-chain transactions and binding them together. While RGB moves data and smart contracts that BTC cannot store or execute to off-chain via client-side validation and binds them to on-chain transactions, RGB++ moves these data and contracts to CKB, making CKB the smart contract settlement layer for BTC.
-
Sources:
-
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
-
Using RGB++, CKB acts as BTC's shadow chain: Serving as a supplementary chain to handle complex logic and smart contract operations that BTC natively cannot process, including those involving Turing machines.
-
Interaction with BTC Network
-
Transaction Occurrence: On the BTC network, users complete transactions via the standard UTXO model, while parts involving smart contract execution are bound to CKB through RGB++ for contract state and data.
-
Validation Logic: Transactions recorded on the BTC network are synchronized with contract states stored on CKB via RGB++. Specific validation logic ensures transaction legitimacy. Whenever a network transaction occurs, RGB++ triggers contract execution on CKB, checking on-chain contract logic against predefined rules—such as whether balances are sufficient, signatures valid, or contract conditions met.
-
-
RGB++ uses Client-Side Validation to ensure privacy and integrity of off-chain data, submitting data to CKB only after successful off-chain validation for final settlement.
-
Asset Issuance and Management: RGB++ allows users to issue assets (e.g., stablecoins, tokens) via off-chain protocols and manage their lifecycle on CKB—not only issuance and circulation but also more complex operations like time locks and conditional payments.
-
RGB++ combines BTC’s high security with CKB’s programmability.
2.2.3 Isomorphic Binding
-
Cross-Chain Synchronization of Assets & States: Isomorphic binding refers to maintaining synchronized assets and states between BTC and CKB (or other UTXO public chains like Cardano) through a binding mechanism. Whenever an asset transaction occurs on the BTC chain, RGB++ maps the corresponding contract state or asset changes onto CKB.
-
Extended UTXO: In isomorphic binding, each UTXO on the BTC chain has a corresponding Cell (UTXO container) on CKB, recording the associated asset state and smart contract conditions.
-
Asset Binding: When users hold certain RGB++ assets on the BTC chain, the corresponding asset state is stored in a Cell on CKB, ensuring consistency of asset information across both chains through isomorphic binding.
-
Transaction Synchronization: When an RGB++ token transaction occurs, the isomorphic binding mechanism generates a Commitment on the BTC network, consumes the corresponding Cell on the CKB chain, and creates new Cells to distribute assets.
-
Advantages of Isomorphic Binding – Empowering BTCFi
-
Smart Contract Support: BTC cannot natively support Turing-complete smart contracts, but through isomorphic binding, CKB can act 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 management of assets circulating on the BTC network via CKB, enabling users to perform complex financial operations through CKB’s flexible programming capabilities without altering BTC’s base protocol.
-
2.2.4 Leap
-
Proposed RGB++ Layer Upgrade: Extends the binding relationship between CKB and BTC to all UTXO chains, enabling cross-chain asset transfers through "re-binding".
-
Bridgeless Cross-Chain Between BTC and Other UTXO Chains: Its core purpose is to enable seamless transfer of RGB++ assets from the BTC chain to other UTXO chains by switching the bound UTXO, supporting asset management and transfer across multiple blockchains.
-
Bridgeless Technology: Leap achieves cross-chain asset transfer via isomorphic binding and switching UTXOs across different chains, without relying on traditional lock-mint cross-chain bridges.
-
Operational Flow: Example. A user can control RGB++ assets originally on the BTC chain via the Cardano chain and split or transfer them on Cardano.
-
Publish Commitment: First, the user publishes a Commitment on the BTC chain declaring intent to unbind the asset tied to the BTC UTXO.
-
Cardano Chain Binding: Next, publish a new Commitment on the Cardano chain to bind 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 condition from the BTC UTXO to the eUTXO on the Cardano chain. This step allows the asset holder to control assets originally on the BTC chain via the Cardano chain.
-
-
CKB’s Role in Leap:
-
CKB plays a role similar to an indexer and Data Availability (DA) layer. All RGB++ asset data remains stored on the CKB chain, with CKB acting as a third-party witness to process Leap requests and ensure cross-chain asset security.
-
CKB provides security and trustworthiness: Compared to common multi-sig or MPC (multi-party computation) mechanisms in traditional cross-chain bridges, CKB offers more reliable security and decentralization properties.
-
2.2.5 RGB++’s Role in Stablecoin Payments
-
Stablecoin Issuance and Circulation: Issue stablecoins on the BTC chain via RGB++, leveraging CKB for intelligent asset management.
-
Cross-Chain Asset Management: Through the combination of RGB++ Layer and CKB, ensure seamless stablecoin payments across different UTXO chains.
-
Smart Contract Support: Provides complex payment conditions, time locks, and other features for stablecoin payments, enhancing flexibility and security.
-
Bridging Role: RGB++ Layer acts as a bridge between BTC (and other UTXO chains) and CKB, extending BTC’s programmability and asset management capabilities, making BTC-based stablecoin payments more diverse and flexible.
2.3 Fiber Network
2.3.1 Fiber Network Overview
-
Fiber Network is a Layer 2 scaling solution on CKB analogous to BTC's Lightning Network: Specifically designed to enhance CKB's off-chain payment capabilities, allowing users to make fast, low-cost payments off-chain. Payment channels reduce mainchain load and increase transaction speed.
-
Off-Chain Payment Characteristics: Fiber Network enables rapid fund transfers off-chain via payment channels, reducing reliance on the CKB mainchain and increasing transaction throughput.
-
Status: As of September 2024, according to mempool data, over $300 million USD worth of funds are deployed in BTC's Lightning Network, with approximately 12,000 nodes forming nearly 50,000 payment channels.
-
Sources:
-
https://hackernoon.com/fiber-network-a-lightning-network-based-on-ckb
2.3.2 Technical Highlights
-
Off-Chain Payment Channels (Fiber Channels): Fiber Network enables direct asset exchange off-chain between users via created payment channels, submitting only the final state to the CKB mainchain for settlement upon channel closure.
-
On-Chain Contracts (HTLC):
-
Similar to BTC's Lightning Network, Fiber Network currently uses Hash Time-Lock Contracts (HTLC) to secure off-chain transactions; if an off-chain transaction isn't confirmed within the agreed time, assets are automatically refunded via HTLC.
-
PTLC: Building on HTLC, Fiber Network improves privacy by avoiding the same cryptographic value across the entire payment path, using PTLC to prevent leakage of transaction linkability.
-
-
Multi-Hop Routing:
-
Like BTC's Lightning Network, Fiber Network supports payment routing through multiple nodes, using Dijkstra's algorithm to find optimal paths, reducing routing fees and increasing success rates for multi-hop payments.
-
-
Monitoring Service – Watchtower:
-
Users can utilize 24/7 monitoring services to watch payment channel states, preventing malicious nodes from attempting double-spending or cheating (e.g., submitting outdated Commit transactions on-chain). The service can automatically track transactions and raise alerts.
-
2.3.3 Differences Between Fiber Network and BTC Lightning Network
-
Multi-Asset Support:
-
BTC Lightning Network only supports off-chain BTC payments. Future upgrades like Taproot Assets may support other assets, but native support is currently limited to BTC.
-
Fiber Network supports multiple assets, including CKB, BTC, and RGB++ stablecoins.
-
-
Transaction Fees and Speed:
-
BTC Lightning Network incurs relatively high BTC fees when opening and closing channels due to operation on the BTC chain. Channel operation costs significantly increase during periods of high BTC transaction fees.
-
Fiber Network, relying on CKB, offers higher TPS and lower transaction fees, resulting in cheaper channel operations and 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 circulation of multiple assets, including native BTC assets (like inscriptions, runes), CKB, and RGB++ native assets (including RUSD).
-
Off-Chain Cross-Chain Payments: Leveraging the RGB++ Layer, assets from any UTXO chain can enter the Lightning Network.
-
Fiber Network and BTC Lightning Network can interconnect: Enabling cross-chain payments (initiated from Fiber Network, received by BTC Lightning Network). Users can use CKB or RGB++ assets via Fiber Network to purchase assets on BTC Lightning Network, ensuring atomicity of cross-chain transactions (no partial success/failure scenarios).
-
2.3.4 Fiber Network’s Role in Stablecoin Payments
-
Fiber Network supports off-chain stablecoin transfers, ensuring immediacy and low cost.
-
By establishing off-chain payment channels, Fiber Network enables users to conduct high-frequency transactions off-chain, reducing pressure on the mainchain.
-
Fiber Network supports cross-chain atomic payments, enabling stablecoin payments to securely span multiple chains.
2.4 Stable++
2.4.1 Stable++ Overview
-
A decentralized, over-collateralized stablecoin protocol within 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 via the RGB++ protocol, leveraging CKB's capabilities for a more native and efficient solution (subject to debate).
-
Fees: Fees are charged when users collateralize BTC/CKB to mint RUSD and when they repay RUSD to redeem BTC/CKB.
-
RUSD Staking: Users can earn governance token STB by lending staked RUSD.
-
Governance Token STB
-
Users can stake STB to participate in liquidation of collateral and earn rewards.
-
Users can stake STB to share in fee revenue.
-
-
Cross-Chain Interoperability: RUSD can be transferred between UTXO chain accounts via RGB++'s isomorphic binding and Leap functionality.
-
Lower Minimum Collateral Ratio (MCR): Thanks to efficient liquidation mechanisms, risks of potential losses for the protocol and stability providers are reduced, thereby lowering requirements for collateral value.
-
Decentralization: Stable++ is a fully decentralized, independently operating protocol requiring no entity control or permission, allowing users to interact freely and securely with the system.
-
Sources:
-
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 – Dual Insurance
-
Overview: The liquidation mechanism is a protective measure triggered when collateral value drops below a critical point (Minimum Collateral Ratio * Borrowed RUSD), ensuring that issued RUSD stablecoins are always sufficiently backed. The system automatically liquidates under-collateralized positions to maintain overall stability.
-
Stability Pool:
-
To address inefficiencies during mass liquidations, Stable++ replaces the auction-based approach common in most lending protocols with a Stability Pool, eliminating the need to find liquidators on the market.
-
Automatic Liquidation: The Stability Pool requires LPs (users) to pre-deposit RUSD as reserves. When liquidation occurs, an equivalent amount of bad debt in RUSD is directly burned from the pool, while the collateral is directly distributed to LPs.
-
By enabling automatic liquidation via the Stability Pool, replacing traditional auctions with direct distribution of excess collateral enhances operational efficiency and stability during widespread liquidations.
-
-
Redistribution
-
Overview: When the Stability Pool lacks sufficient reserves to cover bad debt, the debt and collateral are redistributed among borrowers through a pro-rata mechanism.
-
Debt Redistribution: If the Stability Pool cannot cover all bad debt, the remaining debt is proportionally redistributed among all borrowers.
-
Collateral Distribution: While all borrowers collectively absorb the bad debt, they also receive proportionally distributed excess collateral as a reward.
-
By having all borrowers jointly bear the bad debt, this mechanism ensures no uncovered debt exists in the system, preventing accumulation of systemic risk.
-
2.4.3 Stable++’s Role in Stablecoin Payments
-
The Stable++ protocol generates the stablecoin RUSD, serving as the primary stablecoin used in payments.
-
Stable++ improves traditional over-collateralization methods through innovative liquidation mechanisms, ensuring price stability of RUSD.
-
Leveraging RGB++'s isomorphic binding and Leap capabilities, Stable++ makes RUSD the first truly freely circulating stablecoin across any UTXO-supported chain, further expanding stablecoin liquidity.
2.5 JoyID
2.5.1 What is JoyID?
-
JoyID Passkey Wallet is an encrypted wallet combining Passkey-based key management.
-
Within the Nervos ecosystem, JoyID is designed as a cross-chain, decentralized identity authentication and management tool, enabling users to securely store and use cryptocurrencies and other decentralized applications.
-
Sources:
-
https://nervina.notion.site/JoyID-8645e910ef104962b01bd4835a8ea7dc
-
https://x.com/joy_protocol/status/1836299130345525533
-
2.5.2 Key Features
-
Password and Seed Phrase-Free: Access wallet via biometric authentication, enabling private-key-free login.
-
Supports BTC and Fiber Network: Enables faster, more efficient trading and helps expand CKB's application scenarios.
-
Multi-Chain Support: Supports not only BTC and Nervos CKB, but also ETH and a series of EVM chains.
-
Enhanced Security via Passkey: Passkey generates secp256k1 signatures required for blockchain transactions from secp256r1 signatures tied to hardware devices. Since secp256r1 signatures are never exposed in transactions and are generated only via biometrics, this adds an extra layer of security to the wallet.
-
Combining 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, enabling users to conduct stablecoin payments on the CKB network and manage their RUSD assets and payment channels.
-
With its superior combination of security, usability, and multi-chain support, JoyID further empowers CKB-based stablecoin payments and other transactions.
3. Payment Flow
-
Payment Initiation and Reception: Users can open payment channels via the JoyID wallet to conduct stablecoin payments.
-
Stablecoin Issuance: RGB++ and Stable++ work together—Stable++ mints RUSD by over-collateralizing BTC or CKB, which is then issued on-chain via RGB++.
-
Cross-Chain Transactions & Circulation: Through isomorphic binding and Leap, RGB++ seamlessly connects the BTC chain (and other UTXO chains) with the CKB chain, enabling cross-chain operations of RUSD and other assets across multiple UTXO chains, expanding asset circulation scope while ensuring data synchronization.
-
Transaction Recording and Settlement: The integration of Fiber Network and CKB supports rapid off-chain payment processing, while CKB as the L1 chain guarantees final settlement, ensuring security of all transaction states and assets.
-
Foundation for Complex Transactions: CKB’s virtual machine and Cell model provide the execution environment for smart contracts, supporting complex payment conditions and custom contract logic, while also ensuring the decentralization of the Stable++ protocol.
Join TechFlow official community to stay tuned
Telegram:https://t.me/TechFlowDaily
X (Twitter):https://x.com/TechFlowPost
X (Twitter) EN:https://x.com/BlockFlow_News


















