Skip to main content

Nervos CKB Mainnet - Integration Guide

Connecting to the CKB network is extremely easy and only requires running one node on a machine. Once you've connected to the CKB network, you can use the RPC interface to interacting with the node.

About Nervos CKB

CKB is the layer 1 of Nervos Network, a public/permissionless blockchain. CKB uses Proof of Work and improved Nakamoto consensus to achieve maximized performance on average hardware and internet conditions without sacrificing decentralization and security, which are the core values of blockchain.

Run A CKB Node

You’ll need to deploy nodes to connect with the CKB network, read data from the blockchain, and broadcast transactions onto the CKB network. For more information, please see Run CKB With The Latest Release or Run CKB With Docker. You may also need an indexer to index live cells and transactions, and then you can try CKB Indexer. If you are looking for a one-stop solution that includes both node and indexer, you can try Perkins' Tent.

Server Requirements

  • OS: Ubuntu 18.04 LTS x86_64 (recommended)
  • Processor: Mainstream CPU 4c
  • RAM: 4G
  • Storage: 100G SSD

Writing an integration

Before starting your integration, we recommend reading CKB Transaction Structure RFC to familiarize yourself with an essential data structure in CKB. Some common issues and corresponding example solutions (using CKB SDK Java) are listed below.

Generating and Parsing Address

CKB Address Format is an application-level recommendation for cell lock script display. The lock script consists of three key parameters, including code_hash, hash_type, and args. CKB address packages lock script into a single line, verifiable, and human read friendly format.

Transferring CKB

The transmission of CKB between addresses is divided into three steps, constructing, signing, and submitting the transaction. You can use the following example to understand how to transfer CKB between addresses SingleSigWithCkbIndexerTxExample and TransferAllBalanceWithCkbIndexerExample. If you want to know the signing process, you can check How to sign the transaction. For the calculation of transaction fees, please see the Transaction Fee.

For withdrawal, need to support both transfers to Short Payload Format Address and transfers to Full Payload Format.

Retrieving data from node

You can make a JSON-RPC request to your CKB node with the SDK. There are some CKB SDK Java examples: JSON-RPC Example. Commonly used RPC interfaces are

How to manage cells(like UTXO set)

Cell management mainly affects cell collection and address balance display. There are many ways to manage cells; here are two typical example solutions.

  • Recommended: use CKB Indexer to collect cells and display balance.
    • get_cells_capacity Returns the live cells total capacity by the lock or type script. You can use this RPC to display address balance.
  • Use your UTXO management framework to combine CKB JSON-RPC protocols to scan the entire CKB blockchain.
    • It is not recommended to use the ckb node internal Indexer module to collect live cells, which is very slow and deprecated.

Confirmation count suggestion

Since Nervos CKB network is secured by ASIC PoW miners with extreme hash rate now, it could achieve the same or better security threshold than Ethereum at 24 block confirmations.

Testing

Once you’ve fully integrated with the CKB network, please test on the testnet and mainnet.

Q&A

When you integrate CKB into your system, you may face some challenges. Here is a Q&A that may help you.