Ethereum is a blockchain network, and like all blockchains, it is composed of a sequence of blocks. Each block contains a set of transactions and associated information. In the case of Ethereum, a new block is added to the chain approximately every 16 seconds. This means that every 16-second interval, all transactions that occurred during this period are verified, validated, and added to the network in the form of a new block.
Each Ethereum block has an associated timestamp, which marks the exact time it was created. In a draw, a specific moment is chosen, the draw timestamp. To generate the prizes, we use information from the Ethereum blocks that are immediately before and after this draw timestamp.
The function uses the hashes of these two blocks. By combining these two hash sequences, and through mathematical processes, the function calculates the prizes.
The choice to use the blocks immediately before and after the draw timestamp ensures that the prize generation process is based on data that cannot be predicted or manipulated, ensuring the integrity and fairness of the draw.
The function that extracts the winning numbers is like a mathematical algorithm that uses these hashes to generate a series of prizes. It does this in the following way:
[0, 1, 2, 3, 4].reduce((acum, index) => { const draw_hash = generateHash(hash, prev_hash); const stripped: string = draw_hash.substr(13 * index, 13); const val: number = parseInt(stripped, 16) / Math.pow(2, 52); const num: number = Math.floor(val * 10000); return [...acum, num.toString().padStart(4, '0')]; }, []);
These five numbers are used as prizes.
In this way, using mathematics and the hashes of the Ethereum blocks, the function ensures that the prizes are generated in a fair and unpredictable manner.