Skip to main content
This guide sells 1,000 USDC for IDRX on Base. The same flow works for every pair the API quotes.

Before you start

  • API root: https://staging.app.aile.tech/api/base/v1
  • Network: Base mainnet, chain ID 8453. Staging trades real assets under small limits.
  • Authentication: Authorization: Bearer <AILE_API_KEY>. Aile issues the key; keep it on your backend. GET /quote needs it, the other routes do not. Get an API key.
  • Amounts are strings in base units. USDC has 6 decimals, IDRX 2.
  • A quote is valid for about 30 seconds and pinned to one taker address: the address that will send the fill and receive the bought token. Decide that address before you ask.
1

Read the deployment

config is public and cacheable for 60 s. tokens are the deployment’s tokens, bookTokens the ones added since; both carry address and decimals. Which pairs are actually quoted is a question for /levels, or simply ask for a quote.
2

Read indicative prices (optional)

GET /levels answers every quoted direction in one call, with no key, cacheable for a few seconds. Use it to decide whether to route through Aile and at what size; it never signs or reserves anything.
A direction with firmQuoted: false will not give a quote right now; treat it as absent.
3

Get a quote

What comes back, in short (every amount is a string in base units):The full schema is in the reference. Problems come back as RFC 7807 JSON with a machine-readable reason; the catalogue is in the API overview.
4

Approve and fill

A fill is exact: the transaction either delivers buyAmount or reverts. It uses about 120k gas. If it reverts with OrderExpired, the 30 s passed: request a new quote. BitInvalidatedOrder means this quote was already filled; a quote fills once.
5

Verify what arrived

Read the receipt’s Transfer logs of the bought token to the taker and compare with buyAmount:
Optionally, GET /orders/{orderHash} reports the gateway’s view of the same fill once indexed (orderHash is the EIP-712 hash of quote.order).

Routes used

Filling from a contract rather than a wallet? Read Aggregators and routers: the contract is the taker, and the bought token is paid to it.