Coinflip
Five-minute pooled bets, predetermined future randomness, and proportional winner claims.
Create and join
A creator supplies a nonzero bytes32 lobby name, a side, and a SHOOK wager. The lobby accepts bets until its exact five-minute deadline. The first different account must choose the opposite side, activating the lobby. Once active, new participants may choose either side.
A walletâs first wager in an existing lobby must be at least the creatorâs original initialBet. Subsequent increments may be smaller but must meet minimumWager and the account total cap. A wallet cannot change sides within the same lobby. The creator may add to its original side before an opponent arrives.
Official limits
| Parameter | Value |
|---|---|
| Lobby duration | 5 minutes |
| Minimum wager or valid increment | 1 SHOOK |
| Maximum per wager and cumulative position | 10,000,000 SHOOK |
| Maximum combined pool | 100,000,000 SHOOK |
| Randomness safety delay | 1 minute after deadline, then minute-cohort alignment |
| Randomness authentication timeout | 5 minutes after the selected roundâs scheduled time |
Selecting an outcome
At creation, the contract fixes a future drand round at or after the deadline plus the safety delay, rounded up to a shared minute cohort. After betting closes, finalizeLobby commits the lobby identity, chain, contract, name, timing, and final side totals.
Anyone can settle using previously authenticated randomness, or settleWithSignature can authenticate and settle together. The domain-separated seedâs lowest bit selects the winning side. Stakes affect payouts within that side; they do not change which side the seed selects.
Payout example
Suppose the pool is 10,000 SHOOK, with 6,000 on heads and 4,000 on tails. Decisive settlement sends 50 SHOOK to reserve and 50 to the lottery, leaving 9,900 SHOOK. If heads wins, a 600 SHOOK heads position claims floor(9,900 Ă 600 / 6,000) = 990 SHOOK.
This payout includes returned winning stake. It is not 990 SHOOK of profit. Unequal pools mean a winning bet does not necessarily double, and a heavily crowded winning side can have a poor net return after fees. A losing side receives no game payout.
Claiming and dust
Each winning player calls claimWinnings(lobbyId, receiver) once from its position wallet. Settlement does not automatically send all players their winnings. After all winning weight claims, any pro-rata rounding dust is deposited into reserve. No claim expiry is implemented.
Cancellation
An unactivated lobby can be cancelled after its betting deadline; the creator then claims a full refund. An active lobby can be cancelled when its randomness was not authenticated strictly before the five-minute timeout. A signature authenticated at or after the cutoff cannot revive settlement.
If the round was authenticated in time, later settlement remains possible and timeout cancellation is rejected. Cancelled wagers are refundable without rake and do not become eligible lottery weight.
Source reference
Checked against the source shipped with this documentation. Contract calls and units are detailed in the contract reference.
Imported source files 21
Supporting contracts, interfaces, and libraries imported by the sources above, including their dependencies.