This repository demonstrates the use of the CKB Wallet clients, which interact with a Go-Perun's channel service server to establish a payment channel.
We use various tools to enable a convenient setup for the local development testnet. 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
andawk
:- We modify some fields of the files generated by the
ckb init --chain dev
command usingsed
andawk
.
- We modify some fields of the files generated by the
tmux
andtmuxp
:tmuxp
is a session manager fortmux
that allows to easily create descriptive.yaml
configuration files to create and attach totmux
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.
- 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
make
check out theMakefile
content 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
ckb
with version0.109.0
or higher.ckb-cli
with version1.4.0
or higher.capsule
with version0.9.2
.docker
and a runningdockerd
instance!
Clone this repository:
$ git clone [email protected]:perun-network/perun-nervos-demo
Initiliaze git
submodules and make sure all dependencies are installed.
$ cd perun-nervos-demo
$ git submodule update --init --recursive
Build the demo client:
$ go build -o perun-nervos-demo
Spin up the local testnet. For this change to the perun-nervos-demo/devnet
directory and issue the make dev
command.
NOTE: Make sure you are in a terminal that is not already running within tmux
. make dev
will use this terminal window and create a tmux
session.
$ cd ./devnet
$ make dev
Wait for ~15 seconds. This is the time it takes for the devnet setup to be completed (deployed all contracts, funded testnet accounts etc.).
Run the channel-service servers on another terminal:
$ cd ./channel_service
go run .
If you are comfortable using tmux
you can of course use the devnet
session, otherwise in a new terminal window start the perun-nervos-demo
.
NOTE: Make sure you are in the root directory of the perun-nervos-demo
repository.
$ cd perun-nervos-demo/
$ ./perun-nervos-demo
You will be greeted with a demo window that is split into two panes:
ctrl+a
: Select left panectrl+b
: Select right panetab
: Cycle through selectable fieldsEnter
: Select or confirm highlighted fieldr
: Go back to parent pageq
: Close the demo
Let's use the left side for Alice and the right side for Bob:
We will use Bob to view the channels he has currently open with others and Alice to open a new channel with Bob.
We will use Alice to open a channel with 400 CKBytes.
After issuing the open transaction, we have to wait for it to be confirmed on-chain. Both parties will wait:
After a few seconds the transaction is confirmed on-chain and both parties were able to observe that fact. This will result in both Alice and Bob viewing the now offically established channel.
Let's use Alice to send ten micropayments of 20 CKBytes per payment to Bob via their channel.
We can observe the fact that multiple payments were issued by looking at the channels version number, which was incremented by ten, the amount of micropayments issued by Alice.
Now we use Bob to settle the channel.
After a few seconds the channels settlement is confirmed on-chain and we can view the updated balances for Bob and Alice.