A Solidity implementation of a simple smart contract which illustrates the game of rock-paper-scissors.
No particular installation is required.
- Go to Remix which is an online IDE designed for Solidity.
- Copy the source code from RockPaperScissors.sol, locate it under the browser folder.
- Compile the code by clicking "Start to compile" button under "Compile" tab on the right pane.
- Navigate to "Run" tab, choose JavaScript VM environment.
- Press the deploy button in order to deploy the contract.
- You will now see a contract under "Deployed Contracts" section.
- Then choose any account from "Account" drop-down list. This account will be a player for the game.
- After choosing a player, join the game by pressing the "join" button. Make sure you pay the stake of 1 ether. This can be done by typing '1' next to "Value" and choose "ether" in the drop-down menu.
- Change account and join the game by repeating the processes 7 and 8 above.
- Now press "makeChoice" button to make a choice. A valid choice will be one of "R", "P", "S".
- Repeat again for another account we made.
- Then disclose the game result. This can be done by pressing "disclose" button.
- Once the outcome of the game is disclosed, you will gain/lose 1 ether unless you draw.
- When the game is over, you can repeat the processes 7-13 to play the game again.
- Implement a code for encrypting the user input for security.
- Add timeout logic after a player making a choice.