placeBet is the primary way users interact with Cyphers markets. Before the transaction is submitted, the SDK generates a fresh x25519 keypair, derives a shared secret with the Arcium MXE, and encrypts both the outcome side and stake amount using RescueCipher. Only the encrypted ciphertexts land on-chain - your chosen side remains private even after settlement.
placeBet
Places a single encrypted bet on a YesNo or MultiOutcome market.Parameters
The market PDA to bet on. Must be in the
"betting" phase (active and before lockTimestamp).The outcome index to bet on. For YesNo markets:
0 = NO, 1 = YES. For MultiOutcome markets: 0 through outcomeCount - 1, matching the labels returned by getMarketOptionLabels.Stake in USDC lamports (6 decimal places). The minimum is
market.minBet (typically 1_000_000 = $1). Protocol and LP fees are deducted from this amount; the remainder is your netAmount tracked on-chain.Optional callback invoked at each stage of the bet flow. Use this to drive progress UI - see the stage reference below.
Return value
Solana transaction signature for the
placePrivateBet instruction.The freshly generated x25519 keypair used to encrypt this bet. You must persist
userKeypair.privateKey. Key by (market, betIndex) so you can handle multiple bets on the same market.Zero-based index of this bet within the
(market, user) pair. Increments by one per bet. Needed when fetching the position PDA and when claiming.Progress stages
onProgress is called once for each stage in order. The stage field is one of:
| Stage | Typical duration | What’s happening |
|---|---|---|
"validating" | ~10 ms | Checks market state, amount ≥ minBet, side in range |
"fetching-state" | ~200 ms (cached) | Loads GlobalState, MXE public key, address lookup table |
"encrypting" | ~50 ms | Generates x25519 keypair, derives shared secret, RescueCipher encrypts [amount, side] |
"submitting" | ~1–2 s | Sends the transaction and awaits slot confirmation |
"awaiting-callback" | 8–30 s | Arcium MPC nodes run the circuit and submit the callback |
"refetching" | ~300 ms | Re-fetches the position account to confirm on-chain state |
"done" | - | Flow complete; return value is ready |
The
"awaiting-callback" stage involves a round-trip through the Arcium MPC cluster and typically takes 8–30 seconds on devnet. Display a spinner or streaming label during this stage so users know the network is working, not stalled.Placing bets with progress UI
Multi-bet example (v0.8.0+)
A single user can place multiple bets on the same market. Each bet gets its ownbetIndex starting from 0. Key your saved private key by both market and bet index:
