A simple rock-paper-scissors commit reveal scheme game built on dojo
To install Dojo, use the following commands:
- Follow the instructions at https://book.dojoengine.org/getting-started/installation.html to install Dojo.
Once Dojo is installed, follow these steps:
- Run Katana:
katana --seed 0 --allow-zero-max-fee
- Build the game:
sozo build
- Deploy the game to Katana:
sozo migrate
(you will need to comment out the World address in Scarb.toml, then once deployed uncomment) - Create a game:
sozo execute CreateGame --calldata 3
- Open another terminal and navigate to the
player_two
directory - Join the game as player two:
sozo execute JoinGame --calldata 0
- In the original terminal, commit your Poseidon hash:
sozo execute Commit --calldata=0,214585235161475357424179868697593518496576949055548172335309505920954063106
- In the
player_two
terminal, commit your move:sozo execute Commit --calldata=0,3165026789427940773000938179506358876317298524448703329726057549612803596036
- Reveal player 1's move:
sozo execute Reveal --calldata=0,12345,1
- Reveal player 2's move:
sozo execute Reveal --calldata=0,12345,2
Create a game with any number of rounds
. Once a game is created a challenger can join. Once this happens the game can begin.
- Each player submits a poseidon hash of their move along with a secret via the
Commit
system - Once both moves have been submitted, each player can reveal their move via the
Reveal
system, which checks the hash - Once revealed anyone can call the
Resolve
which will complete the round