🪙Coin Flip
Flip for your luck! Double your $ALPH or lose everything
Probability
Coin Flip uses the random function to decide the outcome of a coin flip with true or false.
```ralph
fn random(max_value: U256) -> (U256){
let seed = u256From32Byte!(blake2b!(toByteVec!(blockTarget!()) ++ toByteVec!(blockTimeStamp!())))
return addModN!(0,seed, max_value)
}
pub fn flip(choice: U256, amount: U256, feeAmount: U256) -> () {
let randomValue = random(2)
// check randomValue == choice for win or lose
}
```Player outcome
Probability
Heads
50%
Tails
50%
Last updated