What it does

Tic-Tac-Toe will allow users to play the game with unknown people and eventually bet some money in a fair game.

The smart contracts are not controlled by any central authority. No backend, data transactions are broadcasted to the blockchain and miners execute them on the involved smart contracts. Smart contracts enforce a set of rules and cannot be altered once deployed. Transaction are always public and verifiable.

Main game scenario:

X opens a game and bets 0.01 ether and appears in a list of users who are up to play. Y sees X on the list and accepts the game by betting 0.01 ether too. X confirms and the game starts. X and Y make their move one after each other. The winner can withdraw 0.02 ether from the contract. If the game is a draw, both users can withdraw their respective money.

Smart Contract operations:

Get a list of games that can be accepted. Get the data of the game at the given ID. Create a game and list it in open games. User accepting it must bet an amount of ether. Accept the game identified by the gameID, and provide a random number to determine who will start first. Confirm the game by checking the random number with the original hash and set the game started. Mark a cell with the player’s symbol. The game is ended if there is a winner or no cells are left, els the turn will be set to the other user. Transfer the money to the player depending on the status and result of the game.

How I built it

NodeJS, Truffle, Ganache, Metamask, Torus login, Solidity, Etehreum

Accomplishments that I'm proud of

Torus login Working around edge cases: - Who starts the game. - If a user waits the game before there is a winner. - If no-one accepts to play the game. - If user forgets to withdraw the money.

What I learned

The decision about who starts the game needs to be random

Working on a commit-reveal scheme, where the creator will send a salted hash of his number and reveal the number afterwards. This is to hide the creator’s random number until both are sent.

What's next for TicTacToe

Implementing a much deeper check of the client environment, detecting Web3 compatibility. Have the contracts metadata and source code automatically published so that they can be viewed and validated.

Built With

Share this project:
×

Updates