GithubHelp home page GithubHelp logo

smart-contract's Introduction

DICE GAME

Example game session using cleos

Prerequisites

  • Wallet must be unlock and have at least the following private keys

    5JXZVqbaH9eNAHH8cNErrgL4dQJcduXQkmfrmaGe55YfCXL212G wallet password: "PW5KHGsffURGQcY8MnoJwYvWNJZfsy6PGFd4KfwmL24V1Sg8nD3SG"

Set dice contract to tamtamtamtam account
cleos -u http://dev.cryptolions.io:38888 set contract tamtamtamtam ./eosbettest12/ -p tamtamtamtam
Check contract ram
$ cleos -u http://dev.cryptolions.io:38888 get account tamtamtamtam
...
memory: 
     quota:     17.32 MiB    used:     786.5 KiB  
call initcontract action to initialize contract with publickey
$ cleos -u http://dev.cryptolions.io:38888 push action tamtamtamtam initcontract '["EOS5ZwsT4k5szwhgbxyoWa5D2tHYAPxEwQKrHxWtU3xnPeJkudLfF"]' -p tamtamtamtam
Check globalvars table
$ cleos -u http://dev.cryptolions.io:38888 get table tamtamtamtam tamtamtamtam globalvars

{
  "rows": [{
      "id": 1,
      "val": 0
    },{
      "id": 2,
      "val": 0
    },{
      "id": 3,
      "val": 0
    },{
      "id": 4,
      "val": 0
    }
  ],
  "more": false
}

$ cleos -u http://dev.cryptolions.io:38888 get table tamtamtamtam tamtamtamtam randkeys
{
  "rows": [{
      "id": 1,
      "key": "EOS5ZwsT4k5szwhgbxyoWa5D2tHYAPxEwQKrHxWtU3xnPeJkudLfF"
    }
  ],
  "more": false
}
Play 3 games with number 50
$ cleos -u http://dev.cryptolions.io:38888 transfer quoxoft quoctest "1.0000 EOS" "50" -p quoxoft

$ cleos -u http://dev.cryptolions.io:38888 transfer quoxoft tamtamtamtam "1.0000 EOS" "50" -p quoxoft

$ cleos -u http://dev.cryptolions.io:38888 transfer quoxoft tamtamtamtam "1.0000 EOS" "50--" -p quoxoft
CCheck active bets
$ cleos -u http://dev.cryptolions.io:38888 get table tamtamtamtam tamtamtamtam activebets
{
  "rows": [{
      "id": "12882289991765449518",
      "bettor": "quoxoft",
      "referral": "tamtamtamtam",
      "bet_amt": 20000,
      "roll_under": 50,
      "seed": "2bba8ca994edfb6d7f9ed20c6218a2186ac81d7c3facd8e8c82e4d8f888262d1",
      "bet_time": "2018-10-25T15:31:03"
    },{
      "id": "16931292269114576153",
      "bettor": "quoxoft",
      "referral": "tamtamtamtam",
      "bet_amt": 10000,
      "roll_under": 50,
      "seed": "8e234f3c1d02de895b411bca0278bed45a663493f66f3667886feeee99d094e0",
      "bet_time": "2018-10-25T15:30:52"
    },{
      "id": "17705483376857615210",
      "bettor": "quoxoft",
      "referral": "tamtamtamtam",
      "bet_amt": 50000,
      "roll_under": 50,
      "seed": "65dbc8ff2147c8ae4afd9e96049ca563ad6475907bbad448545b0587c90c6a59",
      "bet_time": "2018-10-25T15:29:12"
    }
  ],
  "more": false
}
Call resolvebet action to get result, If player win, contrat will send token to their account.
$ cleos -u http://dev.cryptolions.io:38888 push action tamtamtamtam resolvebet '["12882289991765449518", "SIG_K1_K5QwtZxb78YFTykbxz9iQrLj5xSddga6oeiY9Uj8i5xu3ayfdWcDHKQ9TxDAfHa7CJqQLAARR7fmQwEMtQqVmJwop6moWp"]' -p tamtamtamtam
Check remain active bets
$ cleos -u http://dev.cryptolions.io:38888 get table tamtamtamtam tamtamtamtam activebets
{
  "rows": [{
      "id": "16931292269114576153",
      "bettor": "quoxoft",
      "referral": "tamtamtamtam",
      "bet_amt": 10000,
      "roll_under": 50,
      "seed": "8e234f3c1d02de895b411bca0278bed45a663493f66f3667886feeee99d094e0",
      "bet_time": "2018-10-25T15:30:52"
    },{
      "id": "17705483376857615210",
      "bettor": "quoxoft",
      "referral": "tamtamtamtam",
      "bet_amt": 50000,
      "roll_under": 50,
      "seed": "65dbc8ff2147c8ae4afd9e96049ca563ad6475907bbad448545b0587c90c6a59",
      "bet_time": "2018-10-25T15:29:12"
    }
  ],
  "more": false
}
Note: in resolvebet action, we should send signature of registered public key

smart-contract's People

Contributors

arnoldmuimi avatar quocle108 avatar

Watchers

fang qiang 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.