> For the complete documentation index, see [llms.txt](https://docs.luckblocks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luckblocks.com/lotteries/verify.md).

# Verify

Don't Trust Verify

All results can be verified by anyone on smart contract on polygonscan.

Each requests to **Chainlink** has a requestId and a Random Number seed , that it can be seen on each request on logs tab.

![Example of a result log](https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FbJh0TqHyaOXaVGiRsjSR%2Fimage.png?alt=media\&token=840f7a5f-fa1a-4141-8936-df6768faea59)

\
To get requestId from **Chainlink** use read function <mark style="background-color:orange;">requestNumberIndexToRequestId</mark> with the request counter id, (request counter id is a infinite number that increments on each draw starting from 0), to check if requestId matches the request counter id run the read function <mark style="background-color:orange;">requestIdToRequestNumberIndex.</mark><br>

![Using requestId from lottery 0 in requestIdToRequestNumberIndex function](https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2Fs7TvxWlI7AkKPbUl6U7u%2Fimage.png?alt=media\&token=81431f2a-af1e-4918-98cb-d927e0f751be)

\
You can get the random number info on read function <mark style="background-color:orange;">requestNumberIndexToRandomNumber.</mark>

![Using Lottery ID you get random number from chainlink](https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FCewgRJ1D2J9JfF6aGUCB%2Fimage.png?alt=media\&token=e64cb35b-f809-4bde-bd6f-a10f0e6b48c5)

This is the number which we use to generate the results using modulo math, to check the result you need to check number of players at that draw ID running read function <mark style="background-color:orange;">numberOfPlayers</mark> function with draw ID.

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2F5weSuWt1pNhm07dclr3W%2Fimage.png?alt=media&amp;token=3179c192-1dcc-4531-a0f4-12d60ee69fb0" alt=""><figcaption><p>Getting number of players at the request</p></figcaption></figure>

If for example it had 31 players and randomWords as <mark style="color:yellow;">32123300067369566142430597366058144063309315440346383261562471505552091797105</mark>we will use modulo function to get array position like that:

<mark style="color:yellow;">result = 32123300067369566142430597366058144063309315440346383261562471505552091797105% 31</mark>

example on how its done inside the contract:

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2F65ws1nPpha4O0CuM4bzu%2Fimage.png?alt=media&amp;token=2cac3f0f-97d7-46da-9e10-100b290556fe" alt=""><figcaption><p>Getting Raffle with result of chainlink _randomWords and number of players at the draw time to get the ticket ID in the position of array registeredAccts</p></figcaption></figure>

\
**Get ticket ID position on raffle array >**

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FlUrTrahLgBErwqJj5O6Z%2Fimage.png?alt=media&amp;token=e1f9b53f-9d11-415a-bc2c-818b22f24909" alt=""><figcaption><p>on registeredsAccts on you check which ticket ID corresponds to which position, this position is the position that get draws on raffle random number, this position changes based on new tickets leaving the array. Example ID 1 on position 1</p></figcaption></figure>

Inside contract we get the modulo result to find the winner ticket:

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FNGWfXdB95O9l1qQYll2L%2Fimage.png?alt=media&amp;token=319b48ff-c773-416c-b5d9-4d8bc1a7ad9a" alt=""><figcaption><p>Getting winner ticket based on the raffle variable result</p></figcaption></figure>

We then get the owner of that ticket by checking TicketsHistory storage :&#x20;

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FUciSCWV8C3eFENJLAp8K%2Fimage.png?alt=media&amp;token=4c332b61-0b2d-40be-b4d3-98c4fe3890a1" alt=""><figcaption><p>using the current draw ID and obtained ticket ID by random result position</p></figcaption></figure>

You can also check previous jackpot winners with read functions <mark style="background-color:orange;">getJackpotWinnerByLotteryId or JackpotWinHistory</mark>

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FWkdYvia64kmzmaYJUtg3%2Fimage.png?alt=media&amp;token=405f0a0d-fb29-4efa-9210-e6ed7bc120f7" alt=""><figcaption><p>returns winner ticket infos, returns all zero if not drawed yet</p></figcaption></figure>

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FTYuFUYqa91t02yNjJpFq%2Fimage.png?alt=media&amp;token=8eaa0439-9103-4f93-bee2-8810531c9609" alt=""><figcaption><p>returns winner ticket infos, returns all zero if not drawed yet</p></figcaption></figure>

Last winner address with read function <mark style="background-color:orange;">OurLastWinner</mark>

<figure><img src="https://2318706165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnY5syKziggl0r2PH6WM3%2Fuploads%2FpITk3hbFzBrQ8Wm2AuUv%2Fimage.png?alt=media&amp;token=34650c70-99ee-48fc-87f2-f3e03eedd651" alt=""><figcaption></figcaption></figure>

All the code logic can be seen on smart contracts source code which is well commented, like the buy function in **BuyTicket**(), and result getter function on **fulfillRandomWords**() and more.
