A DiceRoll Game : This project is built on the Midnight Network.
This project demonstrates how to derive dice outcomes from entropy, call the contract, and present a clean UI that reflects on-chain state in real time.
This project focuses on verifiable on-chain roll history:
- A 32-byte secret is generated per roll
- Two dice values are derived deterministically
- The DiceRoll contract stores the outcomes and increments roll count
- The UI displays the latest roll and recent history
-
DiceRoll Contract Integration Records two dice values and totals on-chain
-
Deterministic Roll Derivation Dice values are derived from a fresh secret each roll
-
CLI Experience Simple terminal flow for on-chain rolls
-
Web UI (Next.js) Real-time dice visualization and roll history
npm installMake sure Docker is running:
docker run -p 6300:6300 midnightntwrk/proof-server:8.0.3 -- midnight-proof-server -vnpm run compileexport PRIVATE_STATE_PASSWORD='your-strong-password'
npm run deployNotes:
- You’ll be prompted for a seed if not set
- Ensure wallet has at least 1,000,000 DUST
npm run rollVerbose mode:
npm run roll:verboseThe project includes a DiceRoll web frontend.
-
Start the House Server
export PRIVATE_STATE_PASSWORD='your-strong-password' npx tsx src/server.ts
-
Launch the UI
cd ui npm run dev -
Open
http://localhost:3000to roll dice and view roll history.
🎲 Roll initiated
→ Dice values derived from entropy
→ roll_dice called on-chain
🎯 Result: 4 + 2 = 6
✅ Recorded on Midnight
Run tests:
npm testCovers:
- dice value range validation
- deterministic roll derivation
- distribution sanity checks
Showcasing privacy-preserving computation and verifiable execution.