Skip to main content
The minimal integrator path: discover contracts via GraphQL, place on-chain with viem, receive the settle result + Groth16 proof from the API, then claim on-chain in one transaction. Dependencies: viem, socket.io-client, and fetch. No auth, no API keys.

1. Fetch network config

TypeScript
Always resolve chancePool and usdg from this query — never hardcode addresses. See Networks & contracts.

2. Approve USDG

TypeScript

3. Place a bet

Read the live epoch id, then place. A 2× Strike as the simplest example:
TypeScript
The betId is returned by the call and indexed on the BetPlaced event. Check Bet constraints before quoting multiples, and Placing bets for Range / Ladder args.

4. Get the result and proof

Preferred (realtime): subscribe over Socket.IO and wait for bets:update.
TypeScript
Fallback: poll GraphQL betResult.
GraphQL
proof: null means proving is unavailable for that bet — wait for the epoch seed reveal and use plain claim instead. See Results & proofs.

5. Claim with proof

TypeScript
claimWithProof settles the pending bet from the proof and claims in one transaction. If the bet lost, the call settles it and returns without reverting.

Next steps