Quickstart¶
Swap tokens through Vector in three moves: fetch ranked routes for a pair, build executable calldata for the best one, then sign and send that calldata from your own wallet. This walkthrough swaps 0.05 WETH for USDC on Base Sepolia (chain 84532).
Before you start you need an API key — every request carries it in the api-key header (Get API access) — and a wallet funded with WETH and a little ETH for gas on Base Sepolia.
1. Request a quote¶
Call GET /quote with the pair, the amount in base units, and your sender address.
const params = new URLSearchParams({
fromChain: "84532",
toChain: "84532",
fromToken: "0x4200000000000000000000000000000000000006", // WETH
toToken: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", // USDC
amount: "50000000000000000", // 0.05 WETH in base units
sender: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
slippage: "0.5",
});
const res = await fetch(`https://vector.example.com/quote?${params}`, {
headers: { "api-key": process.env.EDITH_API_KEY! },
});
const { data: routes } = await res.json();
You get an array of route candidates, best first (default ranking is max_value — highest output). Trimmed response:
{
"code": 0,
"data": [
{
"amount": "50000000000000000",
"amountOut": "174650000",
"amountUsd": 175.0,
"amountOutUsd": 174.65,
"minAmountOut": "173776750",
"expiry": 1785283290,
"quoteId": "7c9d1f2ab54e0c6d8f3a41b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8",
"routeKind": "sameChainSwap",
"providers": [{ "name": "Uniswap V3", "type": "dex" }],
"path": [
{
"type": "swap",
"provider": { "name": "Uniswap V3", "type": "dex" },
"fromToken": "0x4200000000000000000000000000000000000006",
"toToken": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"amount": "50000000000000000",
"amountOut": "174650000"
}
],
"slippage": 0.5
}
],
"message": "success"
}
Amounts are base-10 integer strings in token base units. A quote is valid for 90 seconds; expiry is the Unix timestamp (seconds) it stops being buildable.
2. Build the transaction¶
POST /build-path re-quotes the pair and returns calldata for the top route.
Warning
Two body fields are capitalized: Amount and Sender. Every other field is camelCase.
curl -X POST "https://vector.example.com/build-path" \
-H "api-key: $EDITH_API_KEY" \
-H "content-type: application/json" \
-d '{
"fromChain": 84532,
"toChain": 84532,
"fromToken": "0x4200000000000000000000000000000000000006",
"toToken": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"Amount": "50000000000000000",
"Sender": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"slippage": 0.5
}'
const res = await fetch("https://vector.example.com/build-path", {
method: "POST",
headers: {
"api-key": process.env.EDITH_API_KEY!,
"content-type": "application/json",
},
body: JSON.stringify({
fromChain: 84532,
toChain: 84532,
fromToken: "0x4200000000000000000000000000000000000006",
toToken: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
Amount: "50000000000000000", // capitalized
Sender: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", // capitalized
slippage: 0.5,
}),
});
const { data: tx } = await res.json();
Response:
{
"code": 0,
"data": {
"allowanceTarget": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"chain": 84532,
"data": "0x38ed17390000000000000000000000004200000000000000000000000000000000000006…",
"expiry": 1785283290,
"gasLimit": "250000",
"simulation": false,
"to": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"value": "0"
},
"message": "success"
}
To execute a specific route from step 1 instead of re-quoting, send its quoteId to POST /build-path-by-id within the 90-second window.
3. Approve and send¶
Two wallet-side actions, using whatever signing library you already have:
- Make sure
allowanceTargethas an ERC-20 allowance for at leastAmountof the input token (a one-timeapprovefrom the sender). - Send a transaction from the sender wallet with the returned
to,data, andvalue, usinggasLimitas your gas ceiling.
Once the transaction confirms on Base Sepolia, the receiver holds at least minAmountOut of USDC — that floor is enforced on-chain, so a price move past your slippage makes the transaction revert instead of filling badly.
Next steps¶
- Gasless swaps with Permit2 — skip the approval and the gas entirely
- End-to-end swap — the full flow with quote selection and status tracking
- API reference — every Vector endpoint