@vrand.io/web
v0.4.0
Published
Verifiable randomness (VRF) for Solana in one line: const r = await vrand.random(). Proofs verified in the browser before you ever see the number. Sessions: sign once, then unlimited prompt-free requests — perfect for on-chain games. Provably fair dice, s
Maintainers
Readme
@vrand.io/web
Verifiable randomness for web apps, in one line.
import { vrand } from "@vrand.io/web";
const r = await vrand.random(); // uniform float in [0,1) — proof-verifiedOne call = one on-chain request on VRAND, the verifiable randomness protocol on Solana: the user's wallet (Phantom/Solflare, or any wallet-adapter) signs one transaction, a bonded prover answers with a VRF proof, and the SDK verifies that proof locally before the promise resolves. A number from this API is never taken on an RPC's word.
Vocabulary you already know
await vrand.randomInt(1, 6); // inclusive, bias-free
await vrand.pick(["red", "green", "blue"]);
await vrand.shuffle(deck); // Fisher–Yates, rejection-sampled
await vrand.coinFlip();
await vrand.weighted(prizes, [80, 15, 5]);
vrand.random((r) => spin(r)); // callback formThe bigger guns
// One request shaped into many outcomes of a single event — one fee:
const draw = await vrand.draw();
draw.int(1, 6); draw.pick(colors); draw.shuffle(deck);
// A batch of INDEPENDENT numbers — one fee per number, each its own proof,
// packed ~6 requests per signature:
const rs = await vrand.randoms(20);
// Sessions: one signature funds a local session key, then everything runs
// prompt-free until you end it (reclaims rent, sweeps the rest back):
const session = await vrand.startSession({ lamports: 0.05e9 });
await session.randoms(60);
await session.end();
// Verifiable draws with receipts anyone can re-verify:
import { deriveWinners } from "@vrand.io/web";
const winners = deriveWinners(draw.record.beta, entrants, 3);
// Get your request-account rent back:
await vrand.reclaim();Why VRAND
- Locally verified, by default. The SDK re-derives the request's committed input from your own seed and re-checks the VRF proof before your code sees a value.
- Delivery has a price — for the prover. Provers post SOL bonds; declare an at-risk amount and a prover that misses its window pays you exactly that, via a permissionless slash.
- Bias-free shaping. Dice, shuffles, weighted picks and floats via rejection sampling — byte-identical Rust and TypeScript implementations pinned by cross-language golden tests.
- Honest terms. Before a wallet's first request, the protocol Terms of Use are shown in full and the wallet signs a standalone on-chain acknowledgment — explicit consent, once per wallet, never a rider on another transaction.
Live on Solana mainnet and devnet.
Zero-code embed
<script src="https://app.vrand.io/widget.js" defer></script>
<div data-vrand-widget></div>Links
- Try it: app.vrand.io
- Docs: docs.vrand.io — start with Add to your app (2 min)
- Protocol: vrand.io
Apache-2.0.
