Exercise 9 from https://github.com/pszal/teaching/blob/master/2020_50.037-Blockchain-Technology/9_Exercises.md
- Deploy the contract.
- Alice calls
registerPlayers
function with input param of a self-chosen random number. Include some ETH to place a bet. - Bob calls
registerPlayers
with his own chosen input number and also the same betting amount that Alice has specified. - Alice then calls the
flipCoin
function to generate the outcome and reveal the winner. - If Alice does not
flipCoin
within the bet expiration period of 3 hours from the time Bob places his bet, Bob can call towithdrawBet
and receive the total bet winnings.
Flip = (Alice's input number + Bob's input number) % 2
Bet = Bob's input number % 2
If Flip == Bet, Bob wins. Otherwise, Alice wins.