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.
This recipe walks through a complete SOL → USDC swap on DFlow: request an order, sign the returned transaction, and submit it through your RPC.
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 SOL_MINT = "So11111111111111111111111111111111111111112";
const AMOUNT = 10_000_000; // 0.01 SOL (9 decimals)
const SLIPPAGE_BPS = 50; // 0.5%
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;
Request an order
GET /order returns a quote and a base64-encoded transaction in one call. Pass userPublicKey so DFlow can construct the transaction for you to sign.
const params = new URLSearchParams({
inputMint: SOL_MINT,
outputMint: DFLOW_SETTLEMENT_MINT,
amount: AMOUNT.toString(),
slippageBps: SLIPPAGE_BPS.toString(),
userPublicKey: keypair.publicKey.toBase58(),
});
const orderResponse = await fetch(
`${DFLOW_TRADE_API_URL}/order?${params}`,
{ headers }
).then((r) => r.json());
Sign and submit
Deserialize the returned transaction, sign it with the user’s keypair, and submit it through your RPC.
const tx = VersionedTransaction.deserialize(
Buffer.from(orderResponse.transaction, "base64")
);
tx.sign([keypair]);
const signature = await connection.sendTransaction(tx);
const explorerUrl = `https://orbmarkets.io/tx/${signature}`;
const { value } = await connection.confirmTransaction(signature, "confirmed");
if (value.err) {
console.log(`Failed: ${JSON.stringify(value.err)}`);
} else {
console.log("Success: trade landed");
}
console.log(` Tx: ${explorerUrl}`);
Spot Trading
How spot trading works on DFlow, and when the intent-based path makes sense.
Add Platform Fees
Monetize trades with builder fees.
Add Priority Fees
Control execution speed with priority fees.
Authenticate Requests
Authenticate requests for production rate limits.
API Routes