Why VRF?
In a slot machine game, randomness is critical. Players need assurance that:- Results cannot be predicted
- Results cannot be manipulated
- Randomness is verifiable on-chain
How It Works
Traditional vs VRF Randomness
| Approach | Problem |
|---|---|
| Block hash | Miners can manipulate |
| Timestamp | Predictable to some degree |
| User seed | User can choose favorable seeds |
| VRF ✅ | Unpredictable, unbiasable, verifiable |
VRF Properties
- Unpredictable - Output cannot be predicted before computation
- Deterministic - Same input always produces same output
- Verifiable - Anyone can verify the output is correct
Integration with Cartridge
Cartridge VRF is built into the Cartridge Controller infrastructure, providing seamless integration for on-chain games.Benefits of Cartridge VRF
- Native Starknet integration - Designed for Cairo contracts
- Low latency - Fast random number generation
- Session key compatible - Works with Cartridge session keys
- Battle-tested - Used by multiple on-chain games
Integration Flow
Grid Generation
The random value is used to determine all 15 grid positions:Symbol Probability Mapping
Verification
Any player can verify that:- The random seed was generated from immutable session data
- The VRF output matches what Cartridge VRF would produce for that seed
- The grid was correctly generated from the random value
- The score was correctly calculated from the grid
Security Considerations
Seed Generation
Seeds are generated from:- Session ID
- Block timestamp
- Caller address
- Previous spin count
No Retry Attacks
Once a spin is requested, the result is determined by VRF output. Players cannot:- Cancel and retry for better results
- Preview results before committing
- Influence the random generation

