perun-polkadot-demo allows you to interact with Perun Payment-Channels over a CLI powered by go-perun.
It connects to our Pallet that runs on a Polkadot Node by using our Polkadot Backend.
The authors take no responsibility for any loss of digital assets or other damage caused by the use of this software.
Do not use this software with real funds.
Running perun-polkadot-demo requires a recent Go installation, see go.mod
for the required version.
# Clone the repository into a directory of your choice
git clone https://github.com/perun-network/perun-polkadot-demo
cd perun-polkadot-demo
# Compile with
go build
# Check that the binary works
./perun-polkadot-demo --help
You can also run the demo via Docker:
docker build -t perun-polkadot-demo .
# Check that the image works
docker run --rm perun-polkadot-demo --help
Currently, the only available sub-command of perun-polkadot-demo is demo
, which starts the CLI node. The node's
configuration file can be chosen with the --config
flag. Two sample
configurations alice.yaml
and bob.yaml
are provided. A default network
configuration for Alice and Bob is provided in file network.yaml
.
In a first terminal, start a development Polkadot Node:
docker run --rm -it -p 9944:9944 ghcr.io/perun-network/polkadot-test-node
In a second terminal, start the node of Alice with
./perun-polkadot-demo demo --config alice.yaml
In a third terminal, start the node of Bob with
./perun-polkadot-demo demo --config bob.yaml
Alternatively you can start the clients via Docker:
docker run --rm -it -v $(pwd):/cfg --net=host perun-polkadot-demo demo --config /cfg/alice.yaml --network /cfg/network.yaml
docker run --rm -it -v $(pwd):/cfg --net=host perun-polkadot-demo demo --config /cfg/bob.yaml --network /cfg/network.yaml
This will only work on Systems that support the --net=host
option. See the docker docs for more info.
Once both CLIs are running, e.g. in Alice's terminal, propose a payment channel to Bob with 100 Dot deposit from both sides via the following command.
> open bob 100 100
In Bobs terminal, accept the appearing channel proposal.
🔁 Incoming channel proposal from alice with funding [My: 100 Dot, Peer: 100 Dot].
Accept (y/n)? > y
You will see a message like "Channel established with…"
in both terminals
after the on-chain funding completed.
Now you can execute off-chain payments, e.g. in Bob's terminal with
> send alice 10
The updated balance will immediately be printed in both terminals, but no transaction will be visible in the ganache's terminal.
You may always check the current status with command info
.
You can also run a performance benchmark with command
> benchmark alice 10 100
which will send 10 Dot in 100 micro-transactions from Bob to Alice. Transaction performance will be printed in a table.
Finally, you can settle the channel on either side with
> close alice
Now you can exit the CLI with command exit
or Ctrl+D
.
Copyright 2021 PolyCrypt GmbH. All rights reserved.
Use of the source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
Contact us at [email protected].