Skip to main content

Overview

The BOB Gateway SDK makes it easy to bring native BTC swaps directly into your app. This guide walks through the complete integration process. We recommend using the API directly, but you may use our SDK for convenience.

What’s new in V3

This guide targets the V3 API. V1 and V2 endpoints remain reachable but are superseded — the SDK calls /v3 under the hood. Upgrading an existing integration? See the Migration Guide.
The V1 API will be deprecated at the end of July 2026 and shut down afterwards. Migrate any V1 integration to V3 before that date — see the Migration Guide. V2 remains supported.
V3 builds on V2 with multi-chain support and richer settlement data:
  • Non-EVM chains (Tron & Solana) — quotes and orders now span EVM, Tron, and Solana as well as Bitcoin. Addresses and token identifiers are 0x… on EVM chains and Base58 on Tron/Solana. executeQuote signs and broadcasts the right transaction shape for each chain; if you build transactions yourself, createOrder returns a tagged union you dispatch on (type: 'evm' | 'tron' | 'solana').
  • ownerAddress (required) and refundAddressgetQuote now takes an ownerAddress (the EVM owner / refund-claimant, also used for order lookup) and an optional Bitcoin refundAddress for onramps. Routes that need an owner but don’t get one fail with MISSING_OWNER_ADDRESS.
  • USD on order infosrcInfo, dstInfo, settled transfers (receivedTokens / refundedTokens), and pendingBtcPayment now each carry an optional usd value (valued at order time). In V2, usd was only on quote amounts and fee-breakdown lines.
  • Affiliate fees on tokenSwaptokenSwap quotes now expose a resolved single affiliate ({ address, bps }), charged by the aggregator on the source chain. Aggregators allow only one partner fee per swap, so passing more than one affiliate returns TOO_MANY_AFFILIATES. onramp/offramp keep the V2 multi-recipient affiliates list (details).
  • Removed parametersgasRefill, strategyAddress/strategyTarget, and strategyMessage are no longer supported and are rejected by the gateway.
  • Paginated getOrdersgetOrders accepts { userAddress, cursor?, limit? } and returns { orders, nextCursor } (carried over from V2). Pass back nextCursor to fetch the next page; a null/missing value means you’ve reached the end (details).
  • Discriminated order statussuccess / refunded are objects carrying receivedTokens / refundedTokens (each entry has chain, token, amount, the settlement txHash, and now usd); status.inProgress.pendingBtcPayment exposes the gateway’s outgoing Bitcoin { txid, amount, usd } on in-progress X-to-BTC orders. Read the destination txHash from the status payload — dstInfo doesn’t carry one.

Installation

Initialize the SDK

Import the GatewayApiClient (exported as GatewaySDK) and create an instance. The constructor takes an optional options object:

Authentication

API keys are optional — the API is reachable without authentication. A key unlocks:
  • Analytics dashboard — your orders, volume, and affiliate earnings
  • Higher rate limits than keyless usage

Partner Onboarding

Get an API key and go live — full flow and contact details
Once you have a key, pass it in the options object:
The API key must be exactly 32 characters long. When provided, the SDK will include it in the Authorization header as a Bearer token (Authorization: Bearer <api-key>). If you’re calling the API directly, set the same header on every V3 request.

Get Available Routes

Fetch all supported routes to show users their options:

Get a Quote

Request a quote for the user’s desired transaction:
On EVM chains, token parameters (fromToken, toToken) must be 0x-prefixed hex addresses, not symbols; on Tron/Solana they are Base58 identifiers. Use getRoutes() to find supported token addresses. For BTC, use the zero address 0x0000000000000000000000000000000000000000.
Display quote fields like fees and estimated time to give users transparency about the transaction. See the section below for how to access these fields.

Understanding Quote Types

The getQuote response is a discriminated union — access fields through the appropriate key:
You don’t need to handle all quote types — the response type matches your fromChain/toChain parameters. fromChain: 'bitcoin' with toChain: 'bob' always returns an onramp quote; a token-to-token pair (including to Tron/Solana) returns a tokenSwap quote.

Execute the Quote

Execute the quote by having the user sign the Bitcoin transaction:
For detailed wallet integration options including Reown AppKit, sats-wagmi, Dynamic.xyz, and more, see the Bitcoin Wallets guide.

Monitor Orders

Fetch a page of the user’s pending and completed orders. getOrders returns { orders, nextCursor } — pass nextCursor back to walk subsequent pages:
If you don’t want to build your own tracking UI, every order has a public status page on the Gateway Explorer that you can link users to directly:
Example: gateway-explorer.gobob.xyz/order/71a070e7-… Use the order ID returned when the order is created. The page shows live status, amounts, and transaction hashes for both sides of the swap — useful as a “track your swap” link in confirmation screens, order history, or notification emails.

Paginating through all orders

nextCursor is null/absent once you’ve reached the last page:
order.dstInfo.amount is the estimated output recorded when the order was created. The settled amount and destination txHash are reported on status.success.receivedTokens (or status.refunded.refundedTokens) once the order resolves.

X to BTC Order Features

For X-to-BTC (BOB → Bitcoin) orders, getOrders surfaces status fields you can act on while the order is still in progress:
While the gateway is settling an X-to-BTC order, status.inProgress.pendingBtcPayment carries the outgoing Bitcoin transaction { txid, amount }. Use it to show the user a “payout in flight” state and link to a block explorer:
Gateway no longer exposes a bumpFeeTx EVM transaction — it manages fee bumps internally for the BTC payout it broadcasts.
If an order gets stuck or needs to be cancelled, the order will include a refundTx to unlock the locked assets:
This action is irreversible. Once refunded, the order cannot be resumed.

Monetization (Affiliate Fees)

Gateway supports affiliate fees out of the box. You set them per-quote via the SDK’s affiliates parameter — an array of { address, bps } pairs. How they’re charged depends on the route:
  • onramp / offramp — fees are deducted at settlement and paid out in USDT on Ethereum to the recipient addresses you specify, regardless of the route. These routes accept multiple recipients per quote.
  • tokenSwap — the fee is charged by the aggregator (Bungee/Velora) on the source chain. Aggregators allow only one partner fee per swap, so a tokenSwap quote accepts exactly one affiliate. Passing more than one returns TOO_MANY_AFFILIATES.
1 bps = 0.01%, so 50 means 0.50%. For the full fee model, see Fees.

Single recipient

Split fees across multiple recipients

onramp and offramp quotes let you split affiliate fees across multiple recipients in a single quote — useful for revenue splits between an aggregator and an underlying integrator, referral programs, or multi-party agreements. (tokenSwap accepts only one affiliate.)

Format and rules

  • Comma-separated <address>:<bps> pairs, no spaces.
  • Each address must be a valid EVM address.
  • Each bps MUST be greater than 0.
  • Omit affiliates or pass an empty array for no affiliate fees.
  • tokenSwap accepts at most one affiliate; more than one returns TOO_MANY_AFFILIATES.
  • The gateway enforces caps on recipient count and total bps. Routes that don’t support affiliate fees return error code AFFILIATE_FEES_NOT_SUPPORTED_FOR_ROUTE — handle this by retrying the quote with affiliates omitted, or surfacing the error to the user.

Reading resolved fees from the quote

onramp and offramp quotes include a resolved affiliates array — each entry has the recipient address and the computed fee amount (with optional USD value). Use it to surface the affiliate split to the user:
tokenSwap quotes instead expose a single resolved affiliate ({ address, bps }, or null for a fee-free swap):

Raw API equivalent

For integrators not using the SDK, pass the same pairs to the V3 quote endpoint as the affiliates query parameter:
URL-encode the comma if your client doesn’t allow raw commas in query strings.

Track your orders and earnings

With an API key you get a partner dashboard on the Gateway Explorer:
It shows your integration’s orders, volume, and — if you charge affiliate fees — your accumulated earnings. For ecosystem-wide activity, see the public Dune dashboard.

Next Steps

Build DeFi Strategies

Create 1-click DeFi actions like staking and lending

Bitcoin Wallets

Detailed guide on wallet integrations

API Reference

Complete API documentation

Example Code

View complete examples on GitHub