MagicBlock VRF gachapon demo that mints a Metaplex Core NFT reward.
The Anchor program keeps one machine PDA with four weighted reward templates.
pull requests MagicBlock VRF randomness, and the consume_pull callback mints
one Metaplex Core asset directly to the player using the selected reward
template.
This is a base-layer VRF example, not a delegated Ephemeral Rollup flow.
- The frontend creates or reuses a local devnet demo wallet.
- The frontend derives a deterministic
machine_idfrom that wallet pubkey, so each wallet sets up one machine. initcreates the machine, treasury PDA, and Core update-authority PDA.upload_configwrites the four weighted NFT templates.pulltransfers the0.01 SOLpull fee to the treasury and requests VRF.- The MagicBlock VRF callback invokes
consume_pull. - The program validates the VRF program identity signer and mints a deterministic Metaplex Core asset PDA for the player.
| Item | Value |
|---|---|
| Program ID | 5q1a1rA56zJTmEUeNdceFGPR6QQRWYmFJjckucTadnDd |
| Solana RPC | https://rpc.magicblock.app/devnet |
| VRF program | Vrf1RNUjXmQGjmQrQLvJHs9SNkvDJEsRVFPkfSQUwGz |
| VRF queue | Cuj97ggrhhidhbu39TijNVqE74xvKJ69gDervRUXAxGh |
| Metaplex Core | CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d |
The frontend uses MagicBlock's Solana devnet RPC,
https://rpc.magicblock.app/devnet. ER endpoints such as
https://devnet.magicblock.app, https://devnet-as.magicblock.app/, and
https://devnet-us.magicblock.app are for delegated-account examples.
| 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 buildRun the repository-managed local tests:
yarn test:localThe default tests cover initialization, config upload, authorization, and PDA derivation. Live VRF and Metaplex Core tests require devnet.
After deploying to devnet, run the live request smoke test:
yarn test:devnet:smokeRun the full devnet e2e cycle:
yarn test:devnet:e2eTo start the frontend application locally:
cd app
yarn
yarn devThe application will be available at http://localhost:3000 or another port if
3000 is already in use.
The app uses a local demo wallet pattern like the Roll Dice example. It stores a
generated devnet keypair in browser localStorage under solanaKeypair; this is
for demos only, not production wallet custody.
Do not commit deploy keypairs. Anchor writes deploy keys to
target/deploy/*-keypair.json; this example ignores generated target files and
keypair JSON files.
To deploy your own copy, generate a new program keypair, update the program ID in these files, then deploy:
programs/gachapon-example/src/lib.rsAnchor.tomlapp/lib/gachapon-devnet.ts
solana-keygen new --no-bip39-passphrase --silent --outfile target/deploy/gachapon_example-keypair.json
anchor build
anchor deploy --provider.cluster devnetAfter deploy, rebuild or restart the frontend so it uses the new program ID.