Skip to main content

Documentation Index

Fetch the complete documentation index at: https://pond.dflow.net/llms.txt

Use this file to discover all available pages before exploring further.

During development, you can use the developer endpoints without an API key. For production use, request an API key for higher rate limits.
There are two ways to buy outcome tokens:
  1. Using the settlement mint (USDC or CASH) is the direct path.
  2. Any other SPL token adds a swap leg first and roughly 50ms of latency.

With USDC or CASH

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.
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 endpoints
const DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
const 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

const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS"; // yesMint or noMint
const 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());
3

Sign and submit

const txBuffer = Buffer.from(order.transaction, "base64");
const transaction = VersionedTransaction.deserialize(txBuffer);

transaction.sign([keypair]);

const signature = await connection.sendRawTransaction(transaction.serialize(), {
  skipPreflight: true,
  maxRetries: 2,
});
console.log(`  Tx: https://orbmarkets.io/tx/${signature}`);

await connection.confirmTransaction({
  signature,
  blockhash: transaction.message.recentBlockhash,
  lastValidBlockHeight: order.lastValidBlockHeight,
});
4

Check order status

const status = await fetch(
  `${DFLOW_TRADE_API_URL}/order-status?signature=${signature}`,
  { headers }
).then((r) => r.json());

console.log(status.status, status.fills);

With any SPL token

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

// Reuses DFLOW_TRADE_API_URL, headers, and keypair from the setup above.
const splInputMint = "So11111111111111111111111111111111111111112"; // SOL
const splOutcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS"; // yesMint or noMint
const 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());
2

Sign and submit

const splTxBuffer = Buffer.from(splOrder.transaction, "base64");
const splTransaction = VersionedTransaction.deserialize(splTxBuffer);

splTransaction.sign([keypair]);

const splSignature = await connection.sendRawTransaction(splTransaction.serialize(), {
  skipPreflight: true,
  maxRetries: 2,
});
console.log(`  Tx: https://orbmarkets.io/tx/${splSignature}`);

await connection.confirmTransaction({
  signature: splSignature,
  blockhash: splTransaction.message.recentBlockhash,
  lastValidBlockHeight: splOrder.lastValidBlockHeight,
});
3

Check order status

const splStatus = await fetch(
  `${DFLOW_TRADE_API_URL}/order-status?signature=${splSignature}`,
  { headers }
).then((r) => r.json());

console.log(splStatus.status, splStatus.fills);

Market initialization

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.

Prediction Market Quickstart

Build a Kalshi prediction market integration end-to-end.

Change Position Size

Increase or decrease an existing prediction market position.

KYC for Kalshi

Verify wallets before they receive Kalshi outcome tokens.

Authenticate Requests

Authenticate requests for production rate limits.

API Routes