Quickstart
Three steps: get a quote, build the transaction, send it. The API is stateless — every call is self-contained.
1. Get a quote
Ask POST /v1/quote what you’d get for swapping amountIn of assetIn into assetOut. amountIn is in the input token’s smallest units — for TON, that’s nanoton (1 TON = 10⁹).
curl -X POST https://chop.ag/api/v1/quote \
-H 'content-type: application/json' \
-d '{
"assetIn": "TON",
"assetOut": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
"amountIn": "1000000000",
"slippageBps": 100
}'You get back per-DEX quotes plus the best route the aggregator picked:
{
"quotes": [
{ "dex": "dedust", "amountOut": "2365064", "gasEstimate": "250000000" },
{ "dex": "stonfi", "amountOut": "2360436", "gasEstimate": "215000000" }
],
"bestRoute": {
"expectedOut": "2365064",
"minAmountOut": "2341413",
"totalGas": "250000000",
"legs": [
{
"dex": "dedust",
"amountIn": "1000000000",
"expectedOut": "2365064",
"minAmountOut": "2341413",
"messageCount": 0
}
]
}
}For larger orders the response will often have multiple legs — chop splits across pools when the gain clears the gas cost. See Routing & splitting.
2. Build a transaction
With the user’s wallet address, ask POST /v1/tx for the on-chain message(s) to broadcast.
curl -X POST https://chop.ag/api/v1/tx \
-H 'content-type: application/json' \
-d '{
"assetIn": "TON",
"assetOut": "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
"amountIn": "1000000000",
"slippageBps": 100,
"userAddress": "UQAJInSAE7GB_bL49OLFYYVHLgmZTMYF31wlJ51XkQJCTFal"
}'The response includes a tonConnect object that maps 1:1 to TonConnect’s sendTransaction argument:
{
"route": { "...": "..." },
"messages": [
{
"to": "EQDa4VOnTYlLvDJ0gZjNYm5PXfSmmtL6Vs6A_CZEtXCNICq_",
"value": "1250000000",
"bodyBoc": "te6ccgEBAQEA…"
}
],
"totalValue": "1250000000",
"tonConnect": {
"validUntil": 1778076501,
"messages": [
{ "address": "EQDa4VOnTYlLv…", "amount": "1250000000", "payload": "te6ccg…" }
]
}
}3. Sign and send
With @tonconnect/ui-react in a browser dapp:
import { useTonConnectUI } from '@tonconnect/ui-react';
const [tonConnectUI] = useTonConnectUI();
const res = await fetch('https://chop.ag/api/v1/tx', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
assetIn: 'TON',
assetOut: USDT_MASTER,
amountIn: '1000000000',
userAddress: connectedAddress,
}),
}).then((r) => r.json());
await tonConnectUI.sendTransaction(res.tonConnect);Server-side, use @ton/ton’s WalletContract with the raw messages:
import { internal, Cell } from '@ton/core';
const messages = res.messages.map((m) =>
internal({
to: m.to,
value: BigInt(m.value),
body: Cell.fromBase64(m.bodyBoc),
bounce: true,
})
);
await wallet.sendTransfer({ seqno, secretKey, messages });That’s it
The full reference is at /v1/quote and /v1/tx. If you’re building a browser dapp, the TonConnect guide walks through the full setup.