Provably Fair Randomness
Lotto Balls uses Chainlink VRF (Verifiable Random Function) to ensure all game outcomes are provably fair and cannot be manipulated.
Why Randomness Matters
In any lottery or gambling game, fair randomness is critical. Players need assurance that:
The house cannot predict or manipulate outcomes
Results cannot be influenced by miners or validators
The randomness source is verifiable and auditable
Chainlink VRF
Chainlink VRF is the industry-standard solution for generating verifiable random numbers on blockchain.
How It Works
Request: When you place a bet, the Lotto Balls contract requests a random number from Chainlink VRF
Generation: Chainlink nodes generate a random number using their private key and your request data
Proof: Along with the random number, a cryptographic proof is generated
Verification: The smart contract verifies the proof before accepting the random number
Resolution: Your bet is resolved using the verified random number
Security Guarantees
Unpredictable: Neither the game operators, miners, nor Chainlink nodes can predict outcomes
Tamper-proof: Any attempt to manipulate the random number would fail cryptographic verification
Transparent: The proof is publicly verifiable on-chain
Number Generation
From a single VRF random word, four numbers are derived:
This process:
Takes the VRF random number
Combines it with the position index (0, 1, 2, 3)
Hashes the combination using keccak256
Takes modulo 10 to get a number 0-9
Each position is derived independently, ensuring uniform distribution.
VRF Parameters
The Lotto Balls contract uses these Chainlink VRF settings:
Confirmations
3
Block confirmations before fulfillment
Callback Gas
800,000
Gas limit for result processing
Num Words
1
Single random word requested
Payment
Native (ETH)
VRF fees paid in ETH
Timeline
After placing a bet:
Transaction confirmed (~12 seconds on Base)
VRF request sent (same block)
Wait for confirmations (3 blocks, ~36 seconds)
VRF fulfillment (Chainlink delivers random number)
Bet resolved (prizes distributed automatically)
Total time: approximately 1-2 minutes
Verifying Fairness
You can verify any game result:
On-Chain Verification
Find the
GameResolvedevent for your betNote the
gameId(VRF request ID)The VRF proof is verified automatically by the contract
Public Audit
All VRF requests and fulfillments are visible on-chain
Chainlink provides a VRF explorer to track requests
Anyone can verify the cryptographic proofs
Emergency Handling
If a VRF callback fails (extremely rare):
The game owner can call
manualOverrideGame(requestId)This unsticks the player without awarding prizes
The player's "pending bet" status is cleared
This is logged via the
ManualGameOverrideevent
This emergency function exists only to prevent players from being permanently locked out of the game in edge cases.
Last updated