API Reference
Swap Build
Build unsigned swap transactions
Builds an unsigned swap transaction (base64). You sign it client-side and then broadcast it.
Platform fees can apply depending on your plan. You can also attach your own fee for your users via feeWallet and feePercent.
Endpoint#
POST /swap/build
Request Body#
| Field | Type | Required | Description |
|---|---|---|---|
| userPublicKey | string | Yes | Your wallet public key |
| inputMint | string | Yes | Token to swap from |
| outputMint | string | Yes | Token to swap to |
| amount | number | Yes | Amount in base units |
| slippageBps | number | Yes | Slippage tolerance (e.g., 500 = 5%) |
| swapType | string | Yes | "buy" or "sell" |
| feeWallet | string | No | Optional fee recipient |
| feePercent | number | No | Optional fee percentage |
Request (curl)#
curl -X POST \
-H "x-api-key: YOUR_KEY" \
-H "content-type: application/json" \
-d '{"userPublicKey":"...","inputMint":"So111...","outputMint":"Es9v...","amount":100000000,"slippageBps":500,"swapType":"buy"}' \
https://us-east.dritan.dev/swap/build
Request (TypeScript, SDK)#
import { DritanClient } from "dritan-sdk";
const client = new DritanClient({ apiKey: "YOUR_KEY" });
const build = await client.buildSwap({
userPublicKey: "YOUR_WALLET_PUBKEY",
inputMint: "So11111111111111111111111111111111111111112",
outputMint: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
amount: 100000000,
slippageBps: 500,
swapType: "buy"
});
Sign the Transaction#
import { VersionedTransaction } from "@solana/web3.js";
const tx = VersionedTransaction.deserialize(
Buffer.from(build.transactionBase64, "base64")
);
const signed = await wallet.signTransaction(tx);
const signedBase64 = Buffer.from(signed.serialize()).toString("base64");