Skip to main content
This guide explains how to pick tokens, preview rates, and handle ERC-20 approvals.
Live source of truth: always call GET /meta/tokens for the supported tokens/addresses in your current environment (Sandbox vs Production). The list below is a snapshot for reference.

Supported tokens (snapshot)

Note: addresses can differ by environment. Always use /meta/tokens in the target environment to get the canonical list (and decimals).

Environment & token mismatch

  • Testnet tokens will not work in Production. Use testnet tokens strictly in Sandbox.
  • If a token isn’t configured for the current environment, the server should return a 400 explaining the mismatch instead of failing later.
Recommended 400 example (orders/create)
Recommended 400 example (quote)
Implementation hint (server-side): validate token → environment at the route layer and map internal lookup errors (e.g., No Web3 instance found for token) to a 400 with a clear message.

Preview a quote (no auth)

Use GET /quote to preview pricing without creating an order. Parameters
  • amount_fiat (KES): positive number
  • token: USDC | USDT | WXM
  • order_type: OnRamp|OffRamp or 0|1 (defaults to OnRamp)
Response
  • rate: KES per token after markup
  • token_amount: tokens the user would receive (OnRamp) or must send (OffRamp)
  • fiat_paid: echo of input
  • symbol, decimals: metadata
Example — OnRamp
Example — OffRamp
Success example
Errors
  • 400 bad_order_typeorder_type must be 0|1 or OnRamp|OffRamp
  • 400 unknown_token / token_env_mismatch
  • 429 rate limited; respect Retry-After
  • 502 upstream price provider error

Units & decimals

  • Fields like token_amount and amount_sent are human units (e.g., 12.34 USDC).
  • ERC-20 approvals must be in base units (integers), using the token’s decimals.
Convert human → base units (ethers v6)

Off-ramp approvals (ERC-20)

Before creating an OffRamp order, approve the Element Pay spender/contract for the token. If allowance is too low, POST /orders/create responds with:
Approve with ethers (v6)
Best practices
  • Approve just-enough (or a reasonable buffer), not unlimited.
  • Reuse allowance across multiple off-ramp orders until depleted.
  • Handle insufficient_balance similarly (you’ll get required vs current in data).

Putting it together

  1. Call /meta/tokens to get supported tokens, addresses, and decimals (for your environment).
  2. Call /quote to preview rate and token_amount before creating an order.
  3. For OffRamp, ensure allowance ≥ required amount (approve if needed).
  4. Create the order via POST /orders/create and track via webhooks or GET /orders/tx/{tx_hash}.
See also
  • API Reference → Quote
  • API Reference → Create Order
  • API Reference → Webhooks