Skip to content

cameronlxu/GuessWhichHand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Guess Which Hand? - Smart Contract Game

๐ŸŽฎ The Game

"Guess Which Hand?" is a smart contract game where a player and a computer pick a choice of 'Left' or 'Right. If the player picks the same move as the computer the player wins. If not, the player loses.

๐Ÿ“— Description

This game is implemented using a smart contract within the Ethereum blockchain. When playing this game, the player will run first run a python script where they pick their move and a password; then is provided a key (combination of the move and password) and a hash of the key via SHA-256.

Once receiving the key & hash, the player will first input the hash value into the smart contract when making their move. When ready to reveal the answer that the computer made, the player will have to input the key provided from the python script. The smart contract will hash this plaintext key via SHA-256 and verify that it is the same hash provided when the player made their move, then set the value of the winner!

๐Ÿš€ Installation & Setup

  1. Clone the repository.
https://github.com/cameronlxu/GuessWhichHand.git
  1. Install MetaMask on your browser (I used Chrome), and be log in.

  2. Add ether in the account, either through a Faucet or Ganache

  3. Open up the Remix IDE.

  4. Import the game.sol script.

๐ŸŽฏ Usage

  1. Run the python script generateMove.py:
python3 generateMove.py
  1. Enter a move "L" or "R", then enter a custom password:

python script

  1. Compile & deploy the smart contract on the Remix IDE.

  2. Regsiter your player:

register player

  1. Copy the hash from the python script results and paste it into the gamePlay function (including the quotes):

game play

  1. Copy the plaintext key from the python script and paste it into the showAnswer function (including the quotes):

show answer

  1. Find out if you won or not!

winner

๐Ÿ–ฅ๏ธ High Level Architecture

architecture

Support

If there are any issues with this bot, please feel free to contact me at: cameron.lau@sjsu.edu!

About

CMPE 183 Project - Crypto & Blockchain. "Guess Which Hand?" Smart Contract Game

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published