createMarket
Creates a YES/NO market. The SDK fetches the current GlobalState to auto-assign the next marketId and accepted mint - you do not need to provide these.
const result = await client.actions.createMarket({
payer: walletPublicKey,
creator: walletPublicKey,
question: "Will BTC close above $100k on 31 Dec 2026?",
closeTime: BigInt(Math.floor(Date.now() / 1000) + 7 * 86400), // 7 days from now
category: 0, // Crypto
resolver: walletPublicKey, // who can call resolveMarket
bondAmount: 20_000_000n, // $20 USDC - minimum is MIN_CREATOR_BOND
challengePeriod: 86400n, // 24 hours - minimum is MIN_CHALLENGE_PERIOD_SECS
});
console.log("Created market", result.marketId, result.signature);Parameters
payer PublicKey required
Transaction fee payer.
creator PublicKey required
Creator's public key. Receives LP fees and can cancel (if no bets) or withdraw funds after resolution.
question string required
Market question, max 200 bytes. For the question to display correctly in the protocol's MarketQuestion PDA, the SDK writes it to a separate account on creation.
closeTime bigint required
Unix timestamp (seconds) when betting closes. Must be at least 60 seconds in the future.
category number required
Market category. See the MarketCategory enum for values (0=Crypto, 1=Politics, 2=Sports, 3=Tech, 4=Economy, 5=Culture, 6=Beyond).
resolver PublicKey required
Wallet that can post the outcome after closeTime. Usually the creator or a trusted oracle.
bondAmount bigint
Creator bond in micro-USDC. Defaults to MIN_CREATOR_BOND ($20). Locked until the creator withdraws after resolution. Pass a larger value to signal stronger commitment.
challengePeriod bigint
Seconds after resolution reveal during which anyone can flag the outcome. Defaults to MIN_CHALLENGE_PERIOD_SECS (24h). Max is MAX_CHALLENGE_PERIOD_SECS (48h).
acceptedMint PublicKey
Override the accepted USDC mint. Defaults to globalState.acceptedMint. Only use this if you need to bypass the GlobalState fetch.
Return value
signature string
Transaction signature.
marketId bigint
The assigned market ID.
marketPda PublicKey
On-chain address of the new market account.
market MarketAccount | null
Market account refetched after creation. Rarely null (RPC lag).
createMarketMulti
Creates a multi-outcome market with 2-4 named options. Embed the option labels in the question using a [A|B|C] suffix.
const result = await client.actions.createMarketMulti({
payer: walletPublicKey,
creator: walletPublicKey,
question: "Which chain leads TVL on 1 Jan 2026? [Solana|Ethereum|Base]",
numOutcomes: 3,
closeTime: BigInt(Math.floor(Date.now() / 1000) + 30 * 86400),
category: 0,
resolver: walletPublicKey,
bondAmount: 20_000_000n,
challengePeriod: 86400n,
});Takes the same parameters as createMarket, plus:
numOutcomes number required
Number of outcomes (2-4). Must match the number of labels in the [A|B|C] suffix.
Note: The
[A|B|C]label suffix is the only way to associate labels with outcome indices. UseparseEmbeddedOptions(question)from@cypher-zk/sdkto extract them on the read side.
cancelMarket
Cancels a market with zero bets and returns the creator's bond. The SDK pre-flights eligibility client-side before sending the transaction.
import { cancelEligibility } from "@cypher-zk/sdk";
// Pre-flight check before showing the cancel button
const market = await client.markets.fetch(marketId);
const elig = cancelEligibility(market);
if (!elig.ok) {
console.log("Cannot cancel:", elig.reason);
return;
}
const result = await client.actions.cancelMarket({
creator: walletPublicKey,
marketId: 42n,
});Note:
cancelEligibility(market)returns{ ok: true, reason: null }or{ ok: false, reason: string }. The SDK calls this internally before sending, but checking it first lets you conditionally render the cancel button.
Parameters
creator PublicKey required
Must match the market's creator field on-chain.
marketId bigint | number required
Market to cancel.
acceptedMint PublicKey
Override the mint (fetched from GlobalState by default).
withdrawCreatorFunds
Pulls the creator's bond and accumulated LP fees from a resolved market.
const result = await client.actions.withdrawCreatorFunds({
creator: walletPublicKey,
marketId: 42n,
});creator PublicKey required
Must match the market's creator on-chain.
marketId bigint | number required
A resolved (state === 2) market.
Note: This can only be called once per market. The
LpPositionAccount.withdrawnflag is set to true after the first call - subsequent calls throwBondAlreadyWithdrawn(error 6020).