cricket
Use

A fair draw

A random number is only half the story. The other half is making sure nobody could have chosen the moment, the list or the round after seeing the result. A draw has three phases.

1. Commit

You fix, before the result exists: the list of entries (as a hash), the number of winners, and the round that will decide. The round must be in the future. The contract refuses a round fewer than 2 rounds (6 seconds) ahead of the current one. Once committed the draw cannot be changed: there is no edit and no cancel.

2. Wait

Nothing happens until the network signs the chosen round. Before that moment its signature does not exist, so nobody, not you, not us, not an operator acting alone, can know the result.

3. Reveal

Anyone posts the 48-byte signature. The contract checks it for that exact round and stores the seed sha256("cricket.v1" || randomness || listHash). Winners are derived from the seed. A draw can be revealed once, by anyone, and only when the round's time has come.

How winners are picked

For the k-th candidate we hash seed || counter (counter on 8 bytes, big-endian), read the result as a 256-bit number and keep value mod total. Two cases are skipped: values from the last, incomplete block of the 2256 range (they would favour small indexes, the modulo bias), and indexes already chosen. The sequence is fixed by the seed, so everybody recomputes the same list, in the same order.

Weights

Every entry has the same chance. For weights, write an entry several times: three lines of the same name means three tickets. There are no hidden weights in the algorithm.

What you must still do

  • Publish the commitment before the round. The page shows the list hash and the round; post them somewhere public. On chain, commit does this for you with the block timestamp.
  • Publish the full list. A hash alone does not let anyone check that their name was in it.
  • Close entries before committing. Otherwise someone can enter after seeing nothing but still gain by timing.
The mistake that breaks everything: choosing the round after you see the signatures. If you can pick among several already-published rounds, you can pick your winner. A draw is only meaningful when the round was fixed in advance, publicly.
ROUND --
next --
$CRICKET 0xb11e...bb13 X