Find something... ⌘K

User flows and examples / Swaps

Pay with USDC

Buy BTC with USDC on Base or Arbitrum, with no gas. The wallet signs once or twice and sends nothing: the solver opens the escrow and pays its gas. Use it when your users hold dollars and no ETH, after a card on-ramp that delivers USDC, or whenever you want the fewest wallet prompts.

ETH, BNB, AVAXUSDC on Base and Arbitrum
Routeevm-btc-escrowevm-btc-gasless
The wallet signsThe orderA permit when needed, and a transfer bound to this order
The wallet sendsOne escrow transactionNothing
POST /orders answerstransaction, simulation, nextsubmitted: true
After thatYou call POST /orders/submitNothing: the solver opens the escrow

Place the order

Quote, sign every signature step, and post the signatures keyed by step id. There is no second call. The samples use the setup from Get a quote.

curlTypeScriptPython
Copy
curl -s -G "$BASE/quote" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=USDC on base" -d to=BTC -d amount=20 \ -d fromAddress="$WALLET" -d toAddress="$MY_BTC_ADDRESS" > quote.json SIGS='{}' for ID in $(jq -r '.steps[] | select(.kind == "signature") | .id' quote.json); do SIG=$(cast wallet sign --private-key "$TEST_WALLET_KEY" --data "$(jq -c --arg id "$ID" '.steps[] | select(.id == $id) | .typedData' quote.json)") SIGS=$(echo "$SIGS" | jq -c --arg id "$ID" --arg sig "$SIG" '. + {($id): $sig}') done curl -s -X POST "$BASE/orders" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \ -d "$(jq -c --argjson sigs "$SIGS" '{order: .order, signatures: $sigs}' quote.json)"

The quote's route is evm-btc-gasless. The wallet signs a USDC permit, when the allowance is short, and a transfer bound to this order. Steps appear only for a wallet that holds the USDC; otherwise issues.balance says what is missing. The sandbox reads no balances, so any wallet works there. Once the escrow opens, the states, webhook and refund rule are the same as paying with ETH: Track the order.

Retrying is safe: the solver opens one escrow per order id. To check the typed data before the wallet opens, compare it with each step's hash, as in Sign.

What the wallet signs

StepWhat it isWhen
permitAn EIP-2612 permit for Permit2, for this order's USDCOnly when the Permit2 allowance does not cover the order
witnessA Permit2 transfer bound to the order idEvery order

Permit2 is at 0x000000000022D473030F116dDEE9F6B43aC78BA3 on every chain. The transfer covers the settlement amount plus the price band, and only this order can use it. In the sandbox the one signature is a MaxySandboxOrder, which authorizes nothing; live, the steps are permit when needed, and witness. More on each step: Approvals and permits.

Before the wallet opens, say: "Sign in your wallet (once or twice). No gas. Your USDC is held by the swap contract until your BTC is sent." More words on the signature screen.

If the solver never opens the escrow

The USDC never left the wallet. The signature lapses 2 hours after the quote and the order reads expired: no solver committed, so nothing left the wallet and there is nothing to refund. (A committed USDC order that is never paid reads refundable and refunds like any other.) Show the user that their USDC is still in their wallet.

With the SDK

buyBtcWithEvm with from: 'USDC on base' runs the same order in one call, signatures included: Flow helpers. After a card on-ramp, quote again once the USDC has landed in the wallet, because a quote names its steps only for a wallet that holds it.