Giter VIP home page Giter VIP logo

perun-polkadot-demo's Introduction


Perun

Polkadot Demo CLI

License: Apache 2.0 CI status

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.

Security Disclaimer

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.

Getting Started

Compilation

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

Docker

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

Demo

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.

Example Walkthrough

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

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].

perun-polkadot-demo's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

perun-polkadot-demo's Issues

Docker build: "go: missing Git command"

Problem:
Error when calling docker build -t perun-polkadot-demo .

#12 4.447 go: missing Git command. See https://golang.org/s/gogetcmd
#12 4.447 error obtaining VCS status: exec: "git": executable file not found in $PATH
#12 4.447       Use -buildvcs=false to disable VCS stamping.

Reason:
go 1.18's alpine image does not contain the git binary, which was included in alpine 1.17.

Proposal:
Add .git to .dockerignore (as git not needed for building in our case)

Automated tests

We could add automated tests as we have for the Ethereum demo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.