Hi, I’m just starting to learn solidity. As a practice project, I’m taking a basic game, say tic tac toe, and adding an option to bet and win (or lose) ETH. The process looks like this:
1) On the front end, call a startGame function in which 1ETH is sent to the smart contract and a log is created (gameID, address, amount, timestamp).
2) Smart contract receives 1 ETH and logs the game. Emit an OK-to-start event.
3) Once the event is heard, load the game in the front end
4) When the game is complete, if the user achieves a certain score, the user should be paid 2 ETH.
Step 4 is where I’m stuck. What is the best way to implement this? I could add a function in which the user can retrieve his winnings at the end of a winning game, but that requires another transaction and a gas fee. Is there a way to do this part without gas?