SDK Reference
TypeScript SDK for the Poll.fun betting protocol on Solana. Build bets, wagers, and voting flows on-chain.
Overview
The @solworks/poll-sdk package is a TypeScript wrapper around the Poll Anchor program. It handles instruction building, transaction signing, account fetching, and PDA derivation — so you can focus on your application logic.
Installation
Install the SDK and its peer dependencies:
npm install @solworks/poll-sdk @coral-xyz/anchor @solana/web3.js @solana/spl-tokenRequires Node.js 18+ and TypeScript 5.0+. See full installation guide →
Quick Example
The full betting lifecycle from creation to settlement in a few SDK calls:
Terminal
example.ts
import { SDK } from "@solworks/poll-sdk";
import { Connection, Keypair } from "@solana/web3.js";
import { Outcome } from "@solworks/poll-sdk";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const wallet = Keypair.generate();
const sdk = SDK.build({ connection, wallet: { publicKey: wallet.publicKey, signTransaction: async (tx) => { tx.sign(wallet); return tx; }, signAllTransactions: async (txs) => { txs.forEach(tx => tx.sign(wallet)); return txs; } } });
// Create a bet
const txHash = await sdk.initializeBetV2({
question: "Will BTC hit $100k by end of 2026?",
expectedUserCount: 10,
minimumVoteCount: 2,
isCreatorResolver: false,
signers: [wallet],
});