How the draw works
Provably Fair Selection Algorithm
A draw is provably fair when the winner is selected deterministically from an unpredictable, publicly verifiable seed. This tool uses the hash of a Bitcoin block as its source of entropy. Because Bitcoin block hashes are generated by decentralized miners solving complex cryptographic puzzles, they cannot be manipulated or predicted beforehand.
1. Hexadecimal to Decimal
The target block hash is a 64-character hexadecimal string. To perform arithmetic, we extract the last 6 characters (which range from 000000 to ffffff) and convert them into a base-10 integer:
This gives us a deterministic number between 0 and 16,777,215.
let decimal = parseInt(blockhash.slice(-6), 16);
2. Selecting the Index
We divide the decimal value by the total number of participants and find the division remainder using the modulo operator (%). The remainder acts as the index pointer:
The index is guaranteed to fall between 0 and competitors.length - 1.
let index = decimal % competitors.length;
let winner = competitors[index];
3. Drawing Multiple Winners
To choose multiple winners without duplicates, the selected winner is removed from the array, shrinking the pool. The script shifts the blockhash slice window one index to the left to extract a new, independent entropy chunk, and recalculates:
// Slice slide loop logic for Winner (N)
let n_decimal = parseInt(blockhash.slice(-(6 + step), blockhash.length - step), 16);
let n_index = n_decimal % competitors.length;