Simple TicTacToe game with betting on the Ethereum Blockchain
We are using the geth client and both websocket and rpc to be able to use remix and receive events.
-
open geth
$ geth --datadir ~/privateEthTestnet --fast --wsapi eth,web3,personal,net,miner,admin --ws --wsaddr "localhost" --wsport "8546" --wsorigins "*" --rpc --rpccorsdomain="*" --rpcapi eth,web3,personal,net,miner,admin
-
attach new instance (new terminal, use 8546 not 8545!):
$ geth attach ws://localhost:8546
-
set account that will receive ether
> miner.setEtherbase(eth.accounts[0])
-
start mining
> miner.start(2)
-
unlock your account:
> personal.unlockAccount(eth.accounts[0], "123456", 999999);
-
Open index.html and you're good to go! The game was developed and tested on Google Chrome only.
-
do 1.-5. from above
-
go to https://remix.ethereum.org/ and chose web3 provider with standard port 8545
-
after connection click create
-
contract should appear in your geth console
-
install remixd
$ npm install -g remixd
$ e.g. remixd -s ~/Documents/gitkrakenRepo/ethTicTacToe and click the link button in remix.
-
click on the connect button in remix
- use save math to increase security
- Make it possible that one address can host multiple games
- Variable pot amount
- bet on games from others
web3.fromWei(eth.getBalance(eth.accounts[1]), "ether")