Skip to content
Java SDK for CKB
Branch: develop
Clone or download
duanyytop Merge pull request #81 from nervosnetwork/master
Merge master(v0.12.0) back to develop
Latest commit 74298f1 May 18, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
config doc: update how to develop in readme Apr 25, 2019
console refactor: refactor wallet and test case May 17, 2019
core refactor: refactor wallet and test case May 17, 2019
utils Merge pull request #74 from BaojunCZ/feat-generate-witness May 16, 2019
.gitignore chore: update type hash to lock hash Apr 1, 2019
.travis.yml add travis ci test Dec 24, 2018 docs: update CHANGELOG for v0.12.0 May 17, 2019
LICENSE Create LICENSE Dec 21, 2018 Update May 8, 2019
build.gradle refactor: refactor wallet and test case May 17, 2019
gradlew Add RPC requests for ckb and add response model for http Dec 21, 2018
gradlew.bat Add RPC requests for ckb and add response model for http Dec 21, 2018
settings.gradle feat: add console module for packing Jan 25, 2019


Build Status

Java SDK for Nervos CKB.


  • Java 8
  • Gradle 5.0 or later


You can generate the jar and import manually.

git clone
gradle shadowJar  // ./gradlew shadowJar 

A console-{version}-all.jar package will be generated, which you can put into your project to develop with it.



You can make JSON-RPC request to your CKB node URL with this SDK. Below are some examples:

CkbService ckbService = HttpService("your-ckb-node-url"));

// using RPC `get_tip_block_number`, it will return the latest block number
BigInteger blockNumber = ckbService.getTipBlockNumber().send().getBlockNumber();

// using RPC `get_block_hash` with block number as parameter, it will return block hash
String blockNumber = "0"
String blockHash = ckbService.getBlockHash(blockNumber).send().getBlockHash();

// using RPC `get_block` with block hash as parameter, it will return block object
Block block = ckbService.getBlock(blockHash).send().getBlock();

You can see more JSON-RPC requests from RPC Document


You can generate ckb address through this SDK as below:

There are many address generating methods, and this is just an example.

// Generate ckb testnet address
AddressUtils utils = new AddressUtils(Network.TESTNET);

// Generate public key from private key through SECP256K1
String publicKey =

String address = utils.generate(publicKey);


We use Google Java Code Format and follow Google Checkstyle for development.

If verifyGoogleJavaFormat FAILED happens when you build this project, please format your code with Google Java Code Format or execute ./gradlew goJF on macOS and Linux, or gradlew goJF on Windows.

If you use IntelliJ IDEA to develop, you can install google-java-format plugin to format code automatically.


The SDK is available as open source under the terms of the MIT License.


See CHANGELOG for more information.

You can’t perform that action at this time.