Requirements
Node.js 18+ (which ships with a built-in global fetch). No extra dependencies are needed for the basic flow.
Generate an outcome
const BASE = "https://api.provable.io";
const clientSeed = "my-app-user-42";
const res = await fetch(
`${BASE}/api/ints?clientSeed=${encodeURIComponent(clientSeed)}&count=5&min=1&max=100`
);
const data = await res.json();
console.log("outcome:", data.outcome);
console.log("serverHash:", data.serverHash);
Verify it later
const verify = await fetch(
`${BASE}/api/verifyServerHash?clientSeed=${encodeURIComponent(clientSeed)}&serverHash=${data.serverHash}`
);
const ok = await verify.json();
console.log(ok ? "✅ verified" : "❌ mismatch");
Tips
- Use a stable
clientSeedper user or per session — that's what ties subsequent verifications back to the original outcome. - Persist the
serverHashalongside whatever you do with the result so you can audit it later. - For richer flows (e.g. running the verification math locally), install the open-source core:
npm install @provableio/provable-core.