Giter Site home page Giter Site logo

perun-polkadot-appdemo's Introduction

perun-polkadot-appdemo: Playing Tic-Tac-Toe on Polkadot in Realtime using Perun Channels

This repository demonstrates a CLI client that uses Perun Channels for trustlessly playing Tic-Tac-Toe for Polkadot tokens in real time.

> set 1 1
Proposing state update: Set mark at (1, 1)
Game state:
x| | 
------
 | | 
------
 | | 
Next actor: Player 2
Balances: [20 0]
Waiting for other player.

Introduction

The repository contains a CLI client that uses perun-polkadot-backend and go-perun to realize the functionality.

  • app: The off-chain definition of the Tic Tac Toe app.
  • cli: The CLI interface.
  • client: The Tic Tac Toe game client.

The client can be started using Go. It takes as input a config file.

go run . -cfg alice.config.json

Once the client is started, an overview of the available commands can be printed using the help command.

> help

Testrun instructions

In the following, we describe how to test the client with a local Polkadot node.

  1. Start a local Polkadot node with the Perun Pallet and the Tic Tac Toe app installed. For example, you can do so using Docker.
docker run --rm -it -p9944:9944 ghcr.io/perun-network/polkadot-test-node:0.3.0
  1. Start client Alice in one terminal.
go run . -cfg alice.config.json
  1. Then start client Bob in a second terminal.
go run . -cfg bob.config.json
  1. Propose game to Bob with stake 10.
propose bob 10
  1. In Bob's terminal, accept the proposal.
accept
  1. In Alice's terminal, set the first mark, e.g., at (2, 2).
set 2 2
  1. In Bob's terminal, set the next mark, e.g., at (1, 1).
set 1 1
  1. Play until game is in final state.
  2. Conclude the game and withdraw the outcome.
settle

Dispute

If the other client isn't responding, you can enforce an action on-chain.

force_set 3 3

At any time, the game can be forced to an end. The funds will be payed out according to the most recent state.

force_settle

Funding

This project has been supported through the German Ministry for Education and Research (BMBF) and the Web3 Foundation.

Copyright

Copyright 2022 PolyCrypt GmbH. Use of the source code is governed by the Apache License, Version 2.0.

perun-polkadot-appdemo's People

Contributors

matthiasgeihs avatar

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.