SDK Class
Complete reference for the SDK class — the primary entry point for the Poll protocol.
Overview
The SDK class is the main entry point for interacting with the Poll.fun betting protocol. Use SDK.build() to create an instance, then call methods to submit transactions or fetch accounts.
SDK.build()
Creates a new SDK instance.
import { SDK } from "@solworks/poll-sdk";
import { Connection } from "@solana/web3.js";
const sdk = SDK.build({
connection: new Connection("https://api.mainnet-beta.solana.com"),
wallet: walletAdapter,
skipPreflight: false,
commitment: "confirmed",
maxRetries: 5,
});| Name | Type | Required | Description |
|---|---|---|---|
| connection | Connection | Yes | Solana RPC connection |
| wallet | IWallet | No | Wallet adapter for signing |
| skipPreflight | boolean | No | Skip preflight transaction checks |
| commitment | Commitment | No | Transaction confirmation level |
| maxRetries | number | No | Max transaction retry attempts |
User methods
createUser()
Creates an onchain program user account for a wallet.
const txHash = await sdk.createUser({
signers: [wallet],
});| Name | Type | Required | Description |
|---|---|---|---|
| signers | Keypair[] | Yes | Transaction signers |
| payerOverride | PublicKey | No | Override fee payer |
| confirmOptions | ConfirmOptions | No | Confirmation options |
Returns Promise<string> — transaction signature.
Bet methods (V2)
initializeBetV2()
Creates a new prediction market.
const txHash = await sdk.initializeBetV2({
question: "Will Bitcoin hit $100k?",
expectedUserCount: 10,
minimumVoteCount: 2,
isCreatorResolver: false,
signers: [wallet],
});| Name | Type | Required | Description |
|---|---|---|---|
| question | string | Yes | Bet question (max 280 chars) |
| expectedUserCount | number | Yes | Maximum participants |
| minimumVoteCount | number | Yes | Votes required for resolution |
| isCreatorResolver | boolean | Yes | If true, creator can resolve without votes |
| signers | Keypair[] | Yes | Transaction signers |
Returns Promise<string> — transaction signature.
placeWagerV2()
Places a USDC wager on a bet outcome.
import { Outcome } from "@solworks/poll-sdk";
const txHash = await sdk.placeWagerV2({
bet: betPublicKey,
amount: 25,
side: Outcome.For,
signers: [wallet],
});| Name | Type | Required | Description |
|---|---|---|---|
| bet | PublicKey | Yes | Bet account address |
| amount | number | No | USDC amount (human-readable) |
| rawAmount | number | No | USDC amount (raw, 6 decimals) |
| side | Outcome | Yes | Outcome.For or Outcome.Against |
| signers | Keypair[] | Yes | Transaction signers |
Returns Promise<string> — transaction signature.
initiateVoteV2()
Starts the voting period for a bet.
const txHash = await sdk.initiateVoteV2({
bet: betPublicKey,
signers: [wallet],
});| Name | Type | Required | Description |
|---|---|---|---|
| bet | PublicKey | Yes | Bet account address |
| signers | Keypair[] | Yes | Transaction signers |
Returns Promise<string> — transaction signature.
placeVoteV2()
Casts a vote on the bet's outcome.
const txHash = await sdk.placeVoteV2({
bet: betPublicKey,
outcome: Outcome.For,
signers: [wallet],
});| Name | Type | Required | Description |
|---|---|---|---|
| bet | PublicKey | Yes | Bet account address |
| outcome | Outcome | Yes | Vote for which outcome wins |
| signers | Keypair[] | Yes | Transaction signers |
Returns Promise<string> — transaction signature.
settleBetBatchV2()
Settles a bet in batches and distributes winnings.
const txHash = await sdk.settleBetBatchV2({
bet: betPublicKey,
batchNumber: 0,
usersPerBatch: 10,
signers: [wallet],
});| Name | Type | Required | Description |
|---|---|---|---|
| bet | PublicKey | Yes | Bet account address |
| batchNumber | number | Yes | Which batch to settle (0-indexed) |
| usersPerBatch | number | Yes | Users per batch |
| signers | Keypair[] | Yes | Transaction signers |
Returns Promise<string> — transaction signature.
Properties
sdk.addressesAddress derivation helpers for all PDAs. See Addresses reference.sdk.accountsAccount fetching helpers with typed return values.sdk.instructionsInstruction builders — get raw TransactionInstruction without broadcasting.sdk.programThe underlying Anchor program instance.sdk.connectionThe Solana RPC connection.sdk.walletThe wallet adapter instance.Static methods
SDK.convertRustEnumValueToString()
Converts raw Rust enum values (stored as objects on-chain) to readable strings.
const statusString = SDK.convertRustEnumValueToString(bet.status);
console.log(statusString); // "Pending", "Resolving", etc.