Drawing Numbers
🎯 Introduction
At the heart of every lottery is its random number generation - the crucial mechanism that determines winners. While traditional lotteries rely on central authorities, Eat the Pie uses Witnet's oracles on World Chain to ensure true randomness. This creates a provably fair system where no single entity can influence the outcome.
🔢 The Drawing Process
Let's break down the intricate process of how random winning numbers are generated:
1. 🚀 Initiating the Draw
- command initiate-draw
using the CLI app
- At a predetermined block (let's call it block X), this function is called to start the drawing process.
- The function will call the witness contract to ask to generate random bytes.
- Ref: smart contract.
2. 🎲 Completing the Draw
- command complete-draw
using the CLI app
- Once the witnet contract has generated the random numbers, function:
setRandomAndWinningNumbers()
can get called. - This will fetch the randomness from the witnet contract and set the winning numbers.
- Ref: smart contract.
3. 🏁 Finalizing the Draw
- command calculate-payouts
using the CLI app
- The function
calculatePayouts()
can now get called, which settles the prizes and winners. - The round is over and users can claim their prizes.
- Ref: smart contract.