This describes how blockchain is used to prove the legitimacy of the lottery and how winners are chosen and paid out. While the game is in progress, only certain details of the blockchain are made public. When the game ends, the entire blockchain will be made public. This is enough information to prove that the entire game is ran by the rules, and that tickets, winners, and payouts are accounted for.

**index**should always be 0 on the first block**timestamp**is when the game began**final_block_salt**is a random value that will be used on the final block (described below)**ticket_price**is the price of each ticket in SMC**game_ends_at_index**and**game_ends_at_timestamp**define when the game ends**rake_percent**is how much of the pot goes to the rake**pick_limits**describes the numbers you can pick (i.e. 1-10 and 1-10)**winner_rules**= first_or_both means you must get the first number right or both numbers right**winner_formula**= first_numericals_plus_1 describes how the final block hash calculates the winner (described below)

Every block from here on will contain a **previous_hash** which refers to the SHA-256 of the previous block.
There are many free tools online to verify the hash is correct.
If you copy the first block text into the tool, the SHA-256 returns **d534d9756c71325c0f5f2b3f46da180bc5f7043824022ea7ff31ac95f9d395e3**.
By changing any part of the text, the entire hash changes. Try it!

**index**increments for every new block**timestamp**is when the ticket was purchased. this is based on the transaction time, not when it was added to blockchain**previous_hash**is the hash of the previous block as described above**player_id**is the SmarterTrade Account ID the ticket was purchased from**pick**is the numbers picked

As each block is added, the previous_hash ensures the previous block can not be changed. This ensures that the rules can not be changed while the lottery is in progress, along with the players and picks.

The next 99 blocks are more tickets. The game will continue until both the **game_ends_at_index** and **game_ends_at_timestamp** are met.

The game is closed and no more tickets can be added. This block is unique in that it offers a few security measures.
The **final_block_salt** was determined in the first block, and in conjunction with the **previous_hash**, we can ensure randomness of the hash of the final block.
All the values of this block are pre-determined, so not even the lottery owner can control the resulting hash.

**timestamp**is missing from this block on purpose**final_block_salt**as defined in the first block

**winning_numbers**is the winning numbers [6,7]**total_pot**is the total pot, equal to ticket_price * number of tickets.**10 * 100 = 1000****total_rake**is the rake, equal to total_pot * rake_percent.**1000 * 0.01 = 10****winners**is a list of the winners. player_id and percent they win

**Winning numbers:** Given the formula **winner_formula=first_numericals_plus_1**, and the **previous_hash** starts with **56fb3**.
We take the first numericals (5 and 6) and add 1 to each (because we can't pick 0), resulting in **winning_numbers=[6, 7]**.
This winner-deciding previous_hash is unpredictable and all numbers are equally likely.

**Winner percents:** Given the rules **winner_rules=first_or_both**. In this example, 9 people won the lottery. 8 got the first number and 1 got both right.
Using "points" to describe how we split up the pot,
each player that got the first number right gets 1 point and each player that got both right gets 10 points (because getting the second number is a 1 in 10 chance).

**(8 * 1) + (1 * 10) = 18 total points**. This means each "small" win is **1 / 18 = 5.5%** and each "big" win is **10 / 18 = 55%**

If there are no big winners, the small winners still split the total pot with the same system. It is also possible for a single player to win two tickets. In this example, if one player had 2 small wins they would get 11%. It is very unlikely that there are no winners, but in that case, there are no winners.

**payouts**is the list of player_id, amount, and SmarterTrade Transaction ID which were paid out

As soon as the lottery ends, the winner payouts are sent to the same account which the tickets were purchased from.

This list should correspond with the amounts in the winner calculation block.
The 8 small winners won 55 each, the big winner won 550. total payout was **8 * 55 + 550 = 990**.
** Final payout amounts are rounded down*

To double check the payout math, our total_pot was 1000, total_rake was 10. **1000 - 10 = 990**.

This is the actual final block. The blockchain is in stone and will not be added to. The results are published for everyone to review and verify.

** This example data was made through a software driven test, so the timestamps are very close together*