Swap
Swap tokens from your agent
ChainHilt asks every enabled DEX aggregator for a quote, picks the best one, and returns the approval and swap transactions for your wallet to sign. Quotes are free; preparing the transactions costs $0.01.
How a swap runs
Quote (free, optional)
POST /api/v1/swap/quotereturns every connector's quote, best first. Execute quotes again on its own, so this step is only for showing prices before committing.Authorize
Call the wallet's
authorize_requestwith the exact execute request: method, URL and JSON body.Execute ($0.01)
Send the request through your x402 client (AgentCash
fetch) with the header it returned.takerAddressis your wallet's address.POST https://chainhilt.ai/api/v1/swap/execute X-ChainHilt-Authorization: <from authorize_request> { "chainId": 8453, "sellToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "buyToken": "0x4200000000000000000000000000000000000006", "sellAmount": "1000000", "takerAddress": "0xE4934BB19E0B97109033dBfDcCc6957E32F9Cc60", "slippageBps": 100 }The response holds ordered actions: up to two approvals, then the swap.
Sign and send
Pass the actions' nonce and hashes to
process_action. The wallet sends them in order and waits for each one to confirm before the next.
Before you sign
- Swaps are not reversible. Confirm the tokens, the amount sold and the minimum received with the user.
sellAmountis in the token's smallest unit. For the chain's native token, use0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEor the zero address.slippageBpsis capped at 5000 (50%). Thin pools need more tolerance than deep ones: pick what the pool needs and confirm it with the user.- Approvals cover exactly the amount sold, never more. When the existing allowance already covers it, no approval is sent.
- Quotes already account for ChainHilt's fee where a connector supports one.
GET /api/v1/swap/connectorslists the enabled aggregators. PassexcludedConnectorsto leave some out.
Endpoints
| Endpoint | Price | What it does |
|---|---|---|
POST /api/v1/swap/quote | Free | Get ranked swap quotes |
POST /api/v1/swap/execute | $0.01 | Select the best available swap quote and return ordered unsigned transaction actions. |
Next
- New here? Start with the quickstart.
- The API reference has the full request and response schemas.