DEV Community

Cover image for Challenge #3: ๐ŸŽฒ Dice Game
Kevin
Kevin

Posted on

Challenge #3: ๐ŸŽฒ Dice Game

Tasks to be done

๐Ÿ’ฌ Dice Game is a contract that allows users to roll the dice to try and win the prize. If players roll either a 0, 1, or 2 they will win the current prize amount. The initial prize is 10% of the contract's balance, which starts out at .05 Eth.

๐Ÿงค Every time a player rolls the dice, they are required to send .002 Eth. 40 percent of this value is added to the current prize amount while the other 60 percent stays in the contract to fund future prizes. Once a prize is won, the new prize amount is set to 10% of the total balance of the DiceGame contract.

๐Ÿงจ Your job is to attack the Dice Game contract! You will create a new contract that will predict the randomness ahead of time and only roll the dice when you're guaranteed to be a winner!

My Review

This was a fairly simple challenge where we just had to copy the dice roll calculation logic from the main contract and make sure that the function is only called if the user is about to win! VRF (verifiable random function) are something new that I got to learn about โœจ Looking forward to randomness someaday being build into the ethereum protocol โœŠ

Important links

Top comments (0)