Perun CKB backend

April 27, 2026 ยท View on GitHub


Perun

Perun CKB Backend

License: Apache 2.0 CI status

Perun CKB backend

This repository contains the Nervos/CKB backend for the go-perun channel library.

Learn how to use go-perun backends in the documentation of the go-perun core library. It supposed to work in tandem with the perun-ckb-contract

This backend supports the following features on CKB:

  • Open and close payment channels on CKB.
  • Support for SUDT tokens in payment channels.
  • Off-chain state updates and signatures.
  • On-chain dispute resolution.
  • Automated tests using a local CKB devnet.

This can be used in combination with other go-perun backends like perun-eth-backend to create cross-chain payment channels.

Project structure

  • backend/: Backend interface implementations.
  • channel/: Channel interface implementations.
  • client/: Client bindings with tests.
  • wallet/: Wallet interface implementations.
  • encoding/: On/off-chain serialization.
  • devnet/: Local devnet deployment.
  • transaction: Contract bindings.

Development

Dependencies

We use various tools to enable a convenient setup for the local development devnet. If you want to use our setup-devnet.sh script, make sure the following commandline tools are installed:

  • jq:
    • Used to parse and edit some configuration files.
  • sed and awk:
    • We modify some fields of the files generated by the ckb init --chain dev command using sed and awk.
  • tmux and tmuxp:
    • tmuxp is a session manager for tmux that allows to easily create descriptive .yaml configuration files to create and attach to tmux sessions.
  • expect:
    • We completely automize the process for test-wallet creation, deploying of contracts etc. To make this work reliably, we use expect which allows to describe how a commandline application is fed input.
  • make:
    • Not strictly necessary, but it should be available on most systems by default. In case you do not want to install make check out the Makefile content and issue the command on your own.
  • ckb with version 0.201.0 or higher.
  • ckb-cli with version 1.13.0 or higher.

Build and Test

  1. Clone the repository.
git clone https://github.com/perun-network/perun-ckb-backend
cd perun-ckb-backend
  1. Initialize the submodule.
git submodule update --init --recursive
  1. Prerequisites: Download ckb-cli and offckb:
npm install -g @offckb/cli

curl -LO https://github.com/nervosnetwork/ckb-cli/releases/download/v1.13.0/ckb-cli_v1.13.0_x86_64-unknown-linux-gnu.tar.gz
tar -xzf ckb-cli_v1.13.0_x86_64-unknown-linux-gnu.tar.gz
sudo cp ckb-cli_v1.13.0_x86_64-unknown-linux-gnu/ckb-cli /usr/local/bin/

curl -LO https://github.com/nervosnetwork/ckb/releases/download/v0.201.0/ckb_v0.201.0_x86_64-unknown-linux-gnu.tar.gz
tar -xzf ckb_v0.201.0_x86_64-unknown-linux-gnu.tar.gz
sudo cp ckb_v0.201.0_x86_64-unknown-linux-gnu/ckb /usr/local/bin/
  1. Start the devnet on a separate terminal and wait for 30 seconds for the devnet to start.
cd devnet

make dev
  1. Run the tests. This step needs a working Go distribution, see go.mod for the required version.
go test ./...

Disclaimer: The tests require at least 3 minutes to complete.

Security Disclaimer

The authors take no responsibility for any loss of digital assets or other damage caused by the use of this software.

Copyright 2025 PolyCrypt GmbH.
Use of the source code is governed by the Apache 2.0 license that can be found in the LICENSE file.