Every market supports both USDC and CASH as settlement mints. Pass your chosen mint as inputMint and the outcome token as outputMint.
1
Set up
Imports, env config, and the wallet/connection used across every step.
Imports, env, and wallet
import "dotenv/config";import { Connection, Keypair, VersionedTransaction } from "@solana/web3.js";import bs58 from "bs58";const DFLOW_TRADE_API_URL = process.env.DFLOW_TRADE_API_URL ?? "https://dev-quote-api.dflow.net";const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpointsconst DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDCconst SOLANA_RPC_URL = process.env.SOLANA_RPC_URL ?? "https://api.mainnet-beta.solana.com";const connection = new Connection(SOLANA_RPC_URL, "confirmed");const keypair = Keypair.fromSecretKey( bs58.decode(process.env.SOLANA_PRIVATE_KEY ?? ""));const headers: HeadersInit = {};if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;
2
Request an order
Request an order
const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS"; // yesMint or noMintconst amount = 1_000_000; // 1 USDC (6 decimals). Contracts can't be bought fractionally, so the amount must be at least the price of one contract.const params = new URLSearchParams({ inputMint: DFLOW_SETTLEMENT_MINT, outputMint: outcomeMint, amount: amount.toString(), userPublicKey: keypair.publicKey.toBase58(),});const order = await fetch( `${DFLOW_TRADE_API_URL}/order?${params}`, { headers }).then((r) => r.json());
The /order endpoint accepts any SPL token as inputMint. It automatically routes through the settlement mint: Input Token → Settlement Mint → Outcome Token. The transaction returned covers both legs.Set amount in the input token’s native decimals (9 for SOL, 6 for USDC).
1
Request an order
Request an order
// Reuses DFLOW_TRADE_API_URL, headers, and keypair from the setup above.const splInputMint = "So11111111111111111111111111111111111111112"; // SOLconst splOutcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS"; // yesMint or noMintconst splAmount = 1_000_000_000; // 1 SOL (9 decimals)const splParams = new URLSearchParams({ inputMint: splInputMint, outputMint: splOutcomeMint, amount: splAmount.toString(), userPublicKey: keypair.publicKey.toBase58(),});const splOrder = await fetch( `${DFLOW_TRADE_API_URL}/order?${splParams}`, { headers }).then((r) => r.json());
The first trade into a market that has not yet been tokenized incurs a one-time fee of approximately 0.02 SOL, paid in SOL. The /order endpoint detects this automatically and includes the initialization instruction in the transaction. No code changes are required.