Skip to main content
The SDK emits 10 typed events via Anchor’s log-based event system. All field names are camelCase (the SDK normalizes from the on-chain snake_case).

WebSocket subscription

Use subscribeAll to listen to every event in real time.
TypeScript
const sub = client.events.subscribeAll((event) => {
  switch (event.name) {
    case "BetPlacedEvent":
      console.log("New bet on", event.data.market.toBase58());
      break;
    case "PayoutClaimedEvent":
      console.log("Payout claimed:", event.data.payoutAmount);
      break;
  }
});

// Tear down when done
sub.unsubscribe();

Typed single-event subscriptions

For type-narrowed callbacks, use the subscribe method or the on* convenience helpers.
TypeScript
// Generic typed subscription
client.events.subscribe("MarketCreatedEvent", (data) => {
  // data is typed as MarketCreatedEvent
  console.log("New market:", data.marketId, data.question);
});

// Convenience helpers
client.events.onBetPlaced((data) => {
  console.log("Bet placed on market", data.market.toBase58());
});

client.events.onPayoutClaimed((data) => {
  console.log("Payout claimed:", data.payoutAmount);
});

Subscription options

TypeScript
const sub = client.events.subscribeAll(callback, {
  commitment: "confirmed",   // "processed" | "confirmed" | "finalized"
  onError: (err, source) => {
    // source: "parse" (log decode error) or "callback" (your handler threw)
    console.error(`Event error [${source}]:`, err);
  },
});
Connection.onLogs does not auto-reconnect after a WebSocket drop. For long-lived subscriptions, detect WS disconnection and call sub.unsubscribe() + re-subscribe.

Poll-based events

For environments without WebSocket support (some mobile wrappers, serverless functions):
TypeScript
const events = await client.events.pollEvents({
  before: "lastSignatureFromPreviousPoll",
  limit: 50,
});

// events: Array<{ signature, slot, event: CypherEvent }>

Parse from transaction logs

If you already have a transaction’s log array (e.g., from sendAndConfirmTransaction), parse events directly:
TypeScript
const events = client.events.parseLogs(txLogs);
// events: CypherEvent[]

Event reference

Emitted when a new market is created.
FieldTypeDescription
marketIdbigintAssigned market ID
marketTypenumber0 = YesNo, 1 = MultiOutcome
categorynumberCategory enum (0-6)
creatorPublicKeyCreator wallet
questionstringMarket question text
closeTimebigintUnix timestamp when betting closes
Emitted when a bet is placed. The amount and side are still encrypted at this point.
FieldTypeDescription
marketPublicKeyMarket PDA
userPublicKeyBettor wallet
encryptedAmountUint8Array32-byte ciphertext
encryptedSideUint8Array32-byte ciphertext
noncebigintEncryption nonce (u128)
entryOddsbigintLocked odds × ODDS_SCALE
Emitted by the Arcium callback after the MPC reveal circuit runs.
FieldTypeDescription
marketPublicKeyMarket PDA
outcomenumberWinning outcome index
revealedPool0bigintRevealed plaintext pool for outcome 0
revealedPool1bigintRevealed plaintext pool for outcome 1
revealedPool2bigintRevealed plaintext pool for outcome 2 (multi)
revealedPool3bigintRevealed plaintext pool for outcome 3 (multi)
payoutRatiobigintPayout per unit stake × ODDS_SCALE
Emitted when a market with zero bets is cancelled.
FieldTypeDescription
marketPublicKeyMarket PDA
creatorPublicKeyCreator wallet
bondReturnedbigintAmount returned to creator
Emitted when the creator pulls their bond + LP fees.
FieldTypeDescription
marketPublicKeyMarket PDA
creatorPublicKeyCreator wallet
bondbigintBond amount returned
lpFeesbigintLP fees earned
totalbigintTotal transferred
Emitted when a winner claims their payout.
FieldTypeDescription
marketPublicKeyMarket PDA
userPublicKeyClaimant wallet
payoutAmountbigintAmount received in micro-USDC
Emitted when a bettor claims a refund from an unresolved market.
FieldTypeDescription
marketPublicKeyMarket PDA
userPublicKeyClaimant wallet
refundAmountbigintAmount refunded in micro-USDC
Emitted when anyone flags a pending resolution during the challenge window.
FieldTypeDescription
marketPublicKeyMarket PDA
flaggedByPublicKeyWallet that raised the flag
Emitted when a pending resolution is finalized after the challenge window elapses undisputed.
FieldTypeDescription
marketPublicKeyMarket PDA
outcomenumberWinning outcome index
payoutRatiobigintFinal payout ratio × ODDS_SCALE
Emitted when an admin overrides a disputed resolution.
FieldTypeDescription
marketPublicKeyMarket PDA
oldOutcomenumberOriginal outcome that was disputed
newOutcomenumberCorrected outcome
newPayoutRatiobigintRecomputed payout ratio
adminPublicKeyAdmin wallet that performed the override