Initialize CypherClient and place your first private bet.
Node.js
React
A self-contained script that lists markets and places a bet using a keypair wallet.
TypeScript
import { Connection, Keypair } from "@solana/web3.js";import { CypherClient, keypairToWallet, marketPhase, saveSecret,} from "@cypher-zk/sdk";const connection = new Connection("https://api.devnet.solana.com", "confirmed");const keypair = Keypair.fromSecretKey(/* your key bytes */);const client = new CypherClient({ connection, wallet: keypairToWallet(keypair), cluster: "devnet",});// List all active marketsconst markets = await client.markets.all();const active = markets.filter( ({ account }) => marketPhase(account) === "betting");console.log(`${active.length} markets open for betting`);// Place a private bet on the first active marketconst { account: market, publicKey: marketPda } = active[0];const result = await client.actions.placeBet({ payer: keypair.publicKey, user: keypair.publicKey, marketId: market.marketId, side: 1, // 1 = YES for YesNo markets amountUsdc: 2_000_000n, // $2.00 USDC (6 decimals) onProgress: ({ stage, message }) => { console.log(`[${stage}] ${message ?? ""}`); },});// Persist the private key immediately - you need it to see your side latersaveSecret(marketPda, result.betIndex, result.userKeypair.privateKey);console.log("Bet placed:", result.signature);console.log("Bet index:", result.betIndex);
Call saveSecret (or store result.userKeypair.privateKey) immediately after the bet lands. If the process exits before you save it, you lose the ability to read your side in the UI. Your funds are still safe - you can still claim.
A minimal React component that lists markets and places a bet with the usePlaceBet hook.First, wrap your app with CypherProvider - see React setup.