Winner Selection
Our automated smart contract randomly selects a winner once the threshold is met and the raffle has expired. Winner selection is verifiable on the blockchain. Instant winner notification.
Overview
Our raffle system uses a transparent, verifiable, and fair process to select winners. The selection happens entirely on the Solana blockchain, which means it's tamper-proof and publicly verifiable.
The Two-Step Process
We use a two-step process to ensure maximum fairness:
Random Ticket Selection: First, our smart contract generates a random winning ticket number
Winner Identification: Then, the system identifies which user purchased that ticket
Technical Implementation
Step 1: Random Ticket Drawing
The smart contract uses Solana's SlotHashes as a source of randomness. Here's what happens:
The contract accesses the most recent SlotHashes sysvar (system variable) on Solana
It extracts the most recent block hash (the first 8 bytes of data)
The contract combines this hash with the current timestamp to create a unique seed value
Using this seed, it generates a number between 0 and the total number of tickets sold (using modulo operation)
This number becomes the winning ticket
This implementation ensures:
No one (not even us) can predict which ticket will win
The randomness comes from the blockchain itself
Anyone can verify the process by checking the transaction on-chain
Step 2: Winner Identification
Once the winning ticket number is determined:
The smart contract searches through all entry records to find which entry contains the winning ticket
Each entry record contains:
The owner's wallet address
The ticket count
The starting ticket index
The entry is found where:
starting_index ≤ winning_ticket < (starting_index + ticket_count)
The owner of this entry is identified as the winner
Verification
Users can verify this process by:
Checking the raffle state on-chain, which includes the winning ticket number
Reviewing the transaction where the winner was determined
Confirming that their entry's ticket range does or doesn't include the winning number
Example
Let's say a raffle sold 100 tickets total:
Alice bought tickets 0-9 (10 tickets)
Bob bought tickets 10-29 (20 tickets)
Charlie bought tickets 30-99 (70 tickets)
If the random process selects ticket #23:
The system identifies that ticket #23 falls within Bob's range (10-29)
Bob is declared the winner
This result is recorded on-chain and cannot be altered
The probability of winning is directly proportional to the number of tickets purchased - Bob had a 20% chance with his 20 tickets.
Last updated