Road to Web3 - Week 8 [Optimism Goerli]
This is a practice project to learn ethers.js and solidity. The eighth week is to build a better game on Optimism smart contract.
➡️ Amazing tutorial here
How to play
- Two parties per game, one is Player Odd (who started the game) and the other is Player Even (who joined the game).
- The game result is determined by the the sum of length of the magic words from both players, if that's odd then Player Odd wins, otherwise Player Even wins.
- Because of there are no real private variables on blockchain, everyone can reveal the data of a smart contract. So the word Player Odd submitted during game creation will be hashed with keccak256.
- After that, Player Even can join the game with word in plaintext.
- Player Odd takes the responsibility to reveal the word after Player Even submitted the word, which must be the same as the word in game creation, verify by the hash on-chain.
- If Player Odd is not revealing the word within a certain time, everyone can help to judge the game and receive a reward of 5% of the game balance, and Player Even will be the winner.
- Cost of starting / joining the game is 0.001 ETH.
- This is only a programming practice and just for fun on testnet.