An Ethereum coin flip contract
This contract is intended to be used by other contracts and not necesariliy by end users. Using WeiFlip is made up of 2 contract calls made in sequence.
The coin flip is perfomed by providing the contract with a random
value and a blockNumber
which must be at least n (default: 7)
blocks in the future.
If sending value with your coin flip you must also pass in a heads_address
and a tails_address
to which all value will be sent depending on the outcome of the flip.
After n
blocks anyone can call the reveal
method with flipId
(returned from previous call and stored in the contract) to have the outcome (and relevent value) sent to the appropriate address.
Prime:
WeiFlip.prime( uint random, uint blockNumber, address heads, address tails )
Returns a flipId
for use in the next call, or 0
if error.
Reveal:
WeiFlip.reveal( uint flipId )
Returns 1
or 2
, for heads or tails, or 0
if error.
Source: w2f3.sol
ABI: w2f3.json