Luckblocks
  • 🎲LuckBlocks - Decentralized Raffles
  • Lotteries
    • BTC Lottery
    • ETH Lottery
    • POL Lottery
    • CRANNI Lottery
    • Verify
  • Auto Spin Draw
    • How queue works
    • How to configure automation
    • Automate Lotteries Bets
  • Cranni Societas - NFTnodes
  • CRANNI Token
    • Synthetic Tokens Overview
    • Additional Features: Overcollateralization and Integration with Luckblocks Lottery
  • Staking
  • Contracts
  • DAPP
  • DAPP(IPFS)
Powered by GitBook
On this page
  1. Lotteries

Verify

Don't Trust Verify

PreviousCRANNI LotteryNextAuto Spin Draw

Last updated 7 months ago

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.

To get requestId from Chainlink use read function requestNumberIndexToRequestId 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 requestIdToRequestNumberIndex.

You can get the random number info on read function requestNumberIndexToRandomNumber.

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 numberOfPlayers function with draw ID.

If for example it had 31 players and randomWords as 32123300067369566142430597366058144063309315440346383261562471505552091797105we will use modulo function to get array position like that:

result = 32123300067369566142430597366058144063309315440346383261562471505552091797105% 31

example on how its done inside the contract:

Get ticket ID position on raffle array >

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

We then get the owner of that ticket by checking TicketsHistory storage :

You can also check previous jackpot winners with read functions getJackpotWinnerByLotteryId or JackpotWinHistory

Last winner address with read function OurLastWinner

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.

Example of a result log
Using requestId from lottery 0 in requestIdToRequestNumberIndex function
Using Lottery ID you get random number from chainlink
Getting number of players at the request
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
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
Getting winner ticket based on the raffle variable result
using the current draw ID and obtained ticket ID by random result position
returns winner ticket infos, returns all zero if not drawed yet
returns winner ticket infos, returns all zero if not drawed yet