# How Are Winners Determined?

Lottery uses works as follows:

1. After the on-going lottery round expires, two block numbers are selected: the latest one on the chain is obtained (Block A) and a future yet-to-be-produced block (Block B).
2. A third random number, $$s$$​ is selected as a salt.
3. Block A and the salt *s* are chained together and hashed with SHA-3 to get a digest *D*.
4. The digest D is put on-chain and the round for the lottery is closed to prohibit the purchase of new tickets.
5. After Block B is mined, both Block A and the salt are uploaded to a random number contract, which verifies that the digest matches the uploaded block number and salt in step 3.
6. The random number contract verifies that the digest matches the uploaded block number and salt and then takes the block hash and salt corresponding to the block number and does a SHA hash to calculate the final lottery result.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swappi.io/swappi/products/lottery/how-are-winners-determined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
