Simple dice rolling application using Ephemeral Rollups to demonstrate using MagicBlock's verifiable random function (VRF) to generate random numbers.
The dice account is delegated to the Ephemeral Rollup. On the ER, the program requests randomness from the VRF oracle with a client seed; the oracle fulfills the request by invoking the program's callback instruction (e.g. CallbackRollDiceSimple) with verified random bytes, which become the dice roll.
https://roll-dice-demo.vercel.app/
This program has utilized the following software packages.
| Software | Version | Installation Guide |
|---|---|---|
| Solana | 3.1.9 | Install Solana |
| Rust | 1.89.0 | Install Rust |
| Anchor | 1.0.2 | Install Anchor |
| Node | 24.10.0 | Install Node |
agave-install init 3.1.9
rustup install 1.89.0
avm use 1.0.2Install dependencies and build the program:
yarn
yarn buildThis example runs against a local MagicBlock cluster — a base Solana validator, an Ephemeral Rollup fronted by the Query Filtering Service, and a VRF oracle that fulfills randomness requests. Start it in one terminal and leave it running:
yarn setupyarn setup runs SETUP_ONLY=1 ./scripts/test-locally.sh roll-dice from the repo root: it builds this example, boots the validators and VRF oracle, and holds them until you press a key.
Then, in a second terminal, run this example's tests against that cluster:
yarn test:localtest:local sources scripts/local-env.sh so the SDK targets the local cluster (without it the tests fall back to devnet).
Tip: to build and run every example end-to-end (what CI does), run the repo-root
./scripts/test-locally.shdirectly.
To start the frontend application locally:
cd appInstall dependencies:
yarn installStart the development server:
yarn devThe application will be available at http://localhost:3000 (or another port if 3000 is already in use).
The delegated dice demo will be available at http://localhost:3000/delegated.