The random processes in the contract need a source of "entropy" to fuel that randomness. Anyone can contribute entropy to the election, both before the election starts (used for the randomness of group meeting assignment) as well as the final sortition round that selects the Head Chief.
▶️ Video Walkthrough of the process described below
During the 24 hours prior to the election's start_time
, you can seed the randomizer! And this can be done again and again; seeds with higher entropy will trump previously-submitted seeds that have less entropy.
To do so, call (with any account) the electseed
action on the contract with a Bitcoin serialized block header from the last hour or so. You should see success. (See Getting Bitcoin Block Header section below for more details.) If you're first, you will also see that the elect.curr
state has updated to current_election_state_seeding
.
start_time
from elect.curr
with this link. Notice:
genesis.eden
elect.curr
table is selected0
start-time
(see section just below)electseed
action hereThe final sortition round needs randomness to be a truly random process. We take randomness from the Bitcoin blockchain.
elect.curr
table with a scope of 0
, and note the start_time
and end_time
. (See instructions just above) because you'll need a block header that was produced in the time window defined by these 2 values, which constitutes a 2-hour period.start_time
and end_time
(see Getting Bitcoin Block Header just below)electseed
with the header as the value here. See the electseed
function and its comments in our election technical doc for more details.Get latest block hash: https://blockstream.info/api/blocks/tip/hash
Alternatively, get hashes (id
) for the last 10 blocks: https://blockstream.info/api/blocks or https://blockstream.info/api/blocks/{$startHeight}
for the 10 blocks starting at the startHeight
.
Get serialized header from hash: https://blockstream.info/api/block/${hash}/header
(e.g., https://blockstream.info/api/block/000000000000000000025181bed97f038c9e0153129f1caed4f5d8959c413592/header)
Note: You can alternatively get a serialized block header from other sites like https://learnmeabitcoin.com/explorer/blockchain/ but you want an appropriately timed header, and on some sites, eg. leanmeabitcoin.com, the header info is often delayed. If it's up-to-date, just click on a later block and toggle to see the header "Serialized."