Skip to main content

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.
TypeScript

Parameters

PublicKey
required
Transaction fee payer.
PublicKey
required
Creator’s public key. Receives LP fees and can cancel (if no bets) or withdraw funds after resolution.
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.
bigint
required
Unix timestamp (seconds) when betting closes. Must be at least 60 seconds in the future.
number
required
Market category. See the MarketCategory enum for values (0=Crypto, 1=Politics, 2=Sports, 3=Tech, 4=Economy, 5=Culture, 6=Beyond).
PublicKey
required
Wallet that can post the outcome after closeTime. Usually the creator or a trusted oracle.
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.
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).
PublicKey
Override the accepted USDC mint. Defaults to globalState.acceptedMint. Only use this if you need to bypass the GlobalState fetch.

Return value

string
Transaction signature.
bigint
The assigned market ID.
PublicKey
On-chain address of the new market account.
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.
TypeScript
Takes the same parameters as createMarket, plus:
number
required
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

PublicKey
required
Must match the market’s creator field on-chain.
bigint | number
required
Market to cancel.
PublicKey
Override the mint (fetched from GlobalState by default).

withdrawCreatorFunds

Pulls the creator’s bond and accumulated LP fees from a resolved market.
TypeScript
PublicKey
required
Must match the market’s creator on-chain.
bigint | number
required
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).