I have created the smart contract named oddEvenGame. First I have declared three state variables named score, isEnded and randNonce.
- Score --> uint256 --> This will store computer's scores.
- isEnded --> bool --> This is a flag for the match is ended or not.
- randNonce --> uint256 --> This will store a random nonce which will help to generate random values.
Then I declared and defined some fuctions like -->
- randomNo --> This is a function which is used to generate random number.
- reset --> This is a function which will reset the value of score to zero and turn the flag isEnded to false to restarts the match. Basically this function restarts the match.
- play --> This function will take a user value ranging from 1 to 6 and checks if the user value is equal to the random generated value or not and and then does the logic part respectively.
First I tested my contract on remix virtual machine then I have deployed the contract to goerli testnet. Goerli testnet address --> 0xCD4288fD856BDbd2ea7dA112936a2f8419435631
Tests -->
- Played the match by putting user input 2.
- Again played the match by putting user input 2.
- Played the match once again by putting the user input 2.
- After the computer got out then I played without hitting the reset button so I got this error that match has ended.. press reset to restart
- Screenshot of deploying the smart contract to goeri nestnet at the address = 0xCD4288fD856BDbd2ea7dA112936a2f8419435631
- Played the game by giving the wrong user input 7. It responded with an error






