1

I am developing Tic-tac-toe game where players can play for ETH. I created a smart contract where a player sends ETH and balances is updates, the player receives some life.

Then I thought when the player plays and win/lose I send a request to a server, and that server sends a transaction to smart contract.

Is that correct way of the implementation or usually developers use another approach?

3

A typical approach would be to set up a contract that accepts stakes from two players per game and then let's them each make moves as they go. The contract would forward the pot to the winner.

A non-obvious but easily addressed issue is the "sore loser" problem. A player who can see he isn't going to win never takes his turn. You just make the contract declare that player forfeits the game after a little time.

A single contract could track many games in progress, with many pots. If you were really serious, you could have players upload funds once into a player account so movement of funds internally is mere accounting. Players would cash out when they don't want to play any more.

There are some jurisdictional regulatory issues outside of the purely technical issues. Caution with that.

Hope it helps.

  • Thank you so much for the answer! So is that a correct way to send a player score from front end to a server, then from the server send a transactions to a smart contract that will update score there? Is that right that I need to create a server that will open some ETH wallet and make that transactions – rel1x Apr 18 '18 at 8:57
  • 1
    There's more than one way to do it. It can be 100% serverless, with users paying a little gas for each move, or you can re-introduce a little bit centralization with a "trusted" server to eliminate transaction costs for all but the "essential" events you need all players to be sure of. – Rob Hitchens - B9lab Apr 18 '18 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.