Step-By-Step Guide
Any Solana program can request and consume verifiable randomness onchain within seconds using the MagicBlock VRF SDK. By the end of this guide, you’ll have a working example that rolls a dice using verifiable randomness.1
Write your Solana program as you normally.
2
Add request and consume randomness instructions.
Add CPI hooks that request and consume randomness via callback from a
verified oracle.
3
Deploy your Solana program using Anchor CLI.
4
Execute transactions for onchain randomness.
Send transactions to generate and consume randomness onchain.
Roll Dice Example

| Software | Version | Installation Guide |
|---|---|---|
| Solana | 2.1.21 | Install Solana |
| Rust | 1.82.0 | Install Rust |
| Anchor | 0.31.1 | Install Anchor |
Quick Access
Find the full basic randomness example for Anchor framework implementation:Code Snippets
- 1. Write program
- 2. Request & Consume Randomnness
- 3. Deploy
- 4. Test
A simple roll dice program where player initialize state account to store, request and consume randomness:⬆️ Back to Top
Solana Explorer
Get insights about your transactions and accounts on Solana:Solana RPC Providers
Send transactions and requests through existing RPC providers:Solana Validator Dashboard
Find real-time updates on Solana’s validator infrastructure:Server Status Subscriptions
Subscribe to Solana’s and MagicBlock’s server status:Solana Status
Subscribe to Solana Server Updates
MagicBlock Status
Subscribe to MagicBlock Server Status
MagicBlock Products
Ephemeral Rollup (ER)
Execute real-time, zero-fee transactions securely on Solana.
Private Ephemeral Rollup (PER)
Protect sensitive data with privacy-preserving computation.
Verifiable Randomness Function (VRF)
Generate provably fair randomness directly on-chain.

