createMarket
Creates a YES/NO market. The SDK fetches the currentGlobalState to auto-assign the next marketId and accepted mint - you do not need to provide these.
TypeScript
Parameters
Transaction fee payer.
Creator’s public key. Receives LP fees and can cancel (if no bets) or withdraw funds after resolution.
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.Unix timestamp (seconds) when betting closes. Must be at least 60 seconds in the future.
Market category. See the MarketCategory enum for values (0=Crypto, 1=Politics, 2=Sports, 3=Tech, 4=Economy, 5=Culture, 6=Beyond).
Wallet that can post the outcome after
closeTime. Usually the creator or a trusted oracle.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.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).Override the accepted USDC mint. Defaults to
globalState.acceptedMint. Only use this if you need to bypass the GlobalState fetch.Return value
Transaction signature.
The assigned market ID.
On-chain address of the new market account.
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.
TypeScript
createMarket, plus:
Number of outcomes (2-4). Must match the number of labels in the
[A|B|C] suffix.The
[A|B|C] label suffix is the only way to associate labels with outcome indices. Use parseEmbeddedOptions(question) from @cypher-zk/sdk to 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.TypeScript
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
Must match the market’s
creator field on-chain.Market to cancel.
Override the mint (fetched from GlobalState by default).
withdrawCreatorFunds
Pulls the creator’s bond and accumulated LP fees from a resolved market.TypeScript
Must match the market’s
creator on-chain.A resolved (
state === 2) market.This can only be called once per market. The
LpPositionAccount.withdrawn flag is set to true after the first call - subsequent calls throw BondAlreadyWithdrawn (error 6020).