Build Multi-Outcome Bets with the Poll SDK

Use the V4 SDK methods when friends need to choose from more than two named outcomes.

Create the bet

Add two or more initial outcomes. The returned bet address identifies the on-chain bet for later calls.

multi-outcome.ts
const { bet, tx } = await sdk.initializeBetV4({
  question: "Who wins Group A?",
  expectedUserCount: 12,
  minimumVoteCount: 3,
  isCreatorResolver: false,
  initialOutcomes: ["Brazil", "Spain", "France"],
  signers: [wallet],
});

console.log(bet.toBase58(), tx);

Add more outcomes

You can add outcomes before the first wager. This is useful for a long list because a Solana transaction has a fixed size limit.

typescript
for (const label of ["Germany", "Japan", "Mexico"]) {
  await sdk.addOutcomeV4({
    bet,
    label,
    signers: [wallet],
  });
}

Place a wager

V4 wager amounts use micro-USDC. One USDC is 1,000,000 micro-USDC. Use an integer string or BN. Do not use floating-point math for money.

typescript
await sdk.placeWagerV4({
  bet,
  amount: "25000000", // 25 USDC
  outcomeIndex: 0, // Brazil
  signers: [wallet],
});

Vote on the result

When the result is known, an eligible participant starts voting. Participants then vote with the same zero-based outcome index that the wager call uses.

typescript
await sdk.initiateVoteV4({
  bet,
  signers: [wallet],
});

await sdk.placeVoteV4({
  bet,
  outcomeIndex: 0,
  signers: [wallet],
});

Settle in batches

After resolution, distribute funds in small batches. Use no more than three users in each V4 settlement transaction.

typescript
await sdk.settleBetBatchV4({
  bet,
  batchNumber: 0,
  usersPerBatch: 3,
  signers: [wallet],
});

Increase batchNumber until all participants are settled. A group of 50 participants needs 17 batches when each batch has three users.

Limits

  • A V4 bet supports 2 to 64 named outcomes.
  • You cannot add an outcome after the first wager.
  • Outcome indexes start at 0 and must match an existing outcome.
  • Use usersPerBatch: 3 or less for V4 settlement.

See the SDK class reference for the complete method parameters.