Perun CKB backend
April 27, 2026 ยท View on GitHub
Perun CKB Backend
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.
sedandawk:- We modify some fields of the files generated by the
ckb init --chain devcommand usingsedandawk.
- We modify some fields of the files generated by the
tmuxandtmuxp:tmuxpis a session manager fortmuxthat allows to easily create descriptive.yamlconfiguration files to create and attach totmuxsessions.
expect:- We completely automize the process for test-wallet creation, deploying of contracts etc. To make this work reliably, we use
expectwhich allows to describe how a commandline application is fed input.
- We completely automize the process for test-wallet creation, deploying of contracts etc. To make this work reliably, we use
make:- Not strictly necessary, but it should be available on most systems by default. In case you do not want to install
makecheck out theMakefilecontent and issue the command on your own.
- Not strictly necessary, but it should be available on most systems by default. In case you do not want to install
ckbwith version0.201.0or higher.ckb-cliwith version1.13.0or higher.
Build and Test
- Clone the repository.
git clone https://github.com/perun-network/perun-ckb-backend
cd perun-ckb-backend
- Initialize the submodule.
git submodule update --init --recursive
- 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/
- Start the devnet on a separate terminal and wait for 30 seconds for the devnet to start.
cd devnet
make dev
- 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
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.
