The app consists of a vendor and a player.
- Player triggers a dice roll game by selecting side count of dice and amount of SOL to bet.
- Vendor creates a DiceRoll game on-chain and saves the bet of the user and sends the equal amount of SOL to DiceRoll PDA. In this step, vendor generates a random seed to be used in the dice roll.
- When the DiceRoll account is created, user generates a random seed and sends approves the Play transaction by sending the bet amount to DiceRoll PDA.
- Play function will combine the vendor hash, player hash and the current timestamp to roll the dice. This way, not a single participant can influence the result as the seeds are aggregated from different sources.
- DiceRoll account sends the amount to the winner, logs the events and closes the account.
- Players play until dices are not equal and player with the highest dice value wins.
Webapp is generated using Next.js and Solana Wallet Adapter.
- Start the local Solana validator
- Deploy the app to local cluster with
anchor deploy
- Run tests with "anchor test"