Giter Club home page Giter Club logo

blox-tictactoe-stakes's Introduction

blox-tictactoe-stakes

Two-player TicTacToe winner-takes-all with EOS stakes via smart contract.

Actions

The smart contract has three actions:

  • newgame(player1, player2, stake): Creates a new game between player1 and player2 for a defined stake. Each player automatically transfers this emount to the contract to keep. On a draw, both players get back their stakes. If a winner is found then that player gets double the initial stake.
  • endgame(player1, player2): Ends game and removes entries from table. If game is not finished then players get their stakes back, but only if no moves have been made.
  • play(player1, player2, row, col): Current player takes turn at row and column position.

Compilation

EOSIO is expected to be compiled and available on the system, especially eosiocpp:

% make
eosiocpp -o TicTacToe.wast TicTacToe.cpp
eosiocpp -g TicTacToe.abi TicTacToe.cpp
Generated TicTacToe.abi ...

Prerequisites

In order for the smart contract to function, the blockchain it is uploaded to must also have the eosio.token contract in order to be able to transfer stakes to winning players from the losers.

Additionally, all attending players must set permission eosio.code for this smart contract. If this contract is uploaded to account tictactoe and user wants to set the permission:

% cleos set account permission user active \
'{"threshold": 1,
  "keys": [{
    "key": "PUBKEY_OF_user",
    "weight": 1
  }],
  "accounts": [{
    "permission": {"actor": "tictactoe",
                   "permission": "eosio.code"},
                   "weight": 1
  }]}' owner -p user

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.