# Other coins

The same order with a different coin. USDC signs without gas, SOL pays from a Solana wallet, and coin to coin moves between EVM chains with no Bitcoin. The samples use the setup from [Get a quote](https://maxy.co/docs/buy-btc#get-a-quote).

## Pay with USDC

USDC on Base and Arbitrum needs no gas. The wallet signs once or twice and sends nothing: the solver opens the escrow.

```sh
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)"
```

```ts
const q = new URLSearchParams({ from: 'USDC on base', to: 'BTC', amount: '20', fromAddress: account.address, toAddress: btcAddress });
const quote = await fetch(`${BASE}/quote?${q}`, { headers: { 'x-maxy-key': KEY } }).then((r) => r.json());
const signatures: Record<string, string> = {};
for (const step of quote.steps.filter((s) => s.kind === 'signature')) signatures[step.id] = await walletClient.signTypedData(step.typedData);

const placed = await fetch(`${BASE}/orders`, {
  method: 'POST',
  headers: { 'x-maxy-key': KEY, 'content-type': 'application/json' },
  body: JSON.stringify({ order: quote.order, signatures }),
}).then((r) => r.json());
console.log(placed.orderId, placed.submitted); // submitted: true, nothing to send
```

```python
quote = requests.get(f"{BASE}/quote", headers={"x-maxy-key": KEY}, params={
    "from": "USDC on base", "to": "BTC", "amount": "20", "fromAddress": account.address, "toAddress": btc_address,
}).json()
signatures = {
    s["id"]: "0x" + bytes(account.sign_message(encode_typed_data(full_message=s["typedData"])).signature).hex()
    for s in quote["steps"] if s["kind"] == "signature"
}
placed = requests.post(f"{BASE}/orders", headers={"x-maxy-key": KEY}, json={"order": quote["order"], "signatures": signatures}).json()
print(placed["orderId"], placed["submitted"])  # submitted: True, nothing to send
```

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. After that, the states, webhook and refund rule are the same.

If the solver never opens the escrow, the USDC never left the wallet: the signature lapses 2 hours after signing, the order reads `refundable`, and there is nothing to refund.

## Pay with SOL

The wallet signs a readable request, then the deposit. The SOL goes into the settlement program's escrow, never to a Maxy address. The sample runs with a test key once `wallet` is yours: your wallet adapter, in the shape below.

```ts
import { createMaxyClient } from '@maxy-labs/sdk/core';
import { buyBtcWithSolana } from '@maxy-labs/sdk/solana';

const wallet = {
  address: publicKey.toBase58(),                                              // the connected wallet
  signMessage: (text) => adapter.signMessage(new TextEncoder().encode(text)), // a readable request
  signTransaction: (base64) => signWithYourAdapter(base64),                   // signs, does not send; answers base64
};
const done = await buyBtcWithSolana({
  client: createMaxyClient(), // reads MAXY_API_KEY
  wallet,
  amount: '1',                // whole SOL
  recipient: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4',
  onProgress: (state) => console.log(state),
});
console.log(done.order.state, done.bitcoinTxid);
```

1. The solver opens its offer on chain.
2. The SOL locks in the program's escrow.
3. The solver pays the BTC to the user's address.
4. The payment is proven on Solana after one Bitcoin confirmation, and the SOL goes to the solver.

An offer the user never funds expires after 10 minutes (`quote_expired`: quote again). An escrow whose BTC is never proven refunds the user's wallet when it expires. The smallest order is about $2. Live, the BTC can go to a `bc1q…` or a `bc1p…` address; the sandbox takes `bc1q…` only.

**Over HTTP:** `GET /quote` with `from=SOL`, sign the `quote` step's `message`, `POST /orders`, sign the deposit it returns, then post it to `POST /orders/{id}/steps`. Track with `GET /status?orderId=…&route=sol-btc`.

**The other way,** BTC to SOL: `GET /quote` with `from=BTC&to=SOL`, then follow `steps`, or use `swap.createBtcToSolOrder` and `swap.settleBtcToSol`. If the fresh price is over 0.1% below the quote, the answer is `quote_mismatch`: quote again.

## Coin to coin

Move a coin between EVM chains, with no Bitcoin involved, on route `cross-evm`. The wallet sends one checked transaction to a bridge. Maxy's settler takes no part, and Maxy never holds the coins. Maxy uses a settler route whenever one exists. Use this one to get a coin onto a chain and token a Bitcoin swap accepts.

```sh
curl -s -G "$BASE/quote" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=ETH on base" --data-urlencode "to=ETH on arbitrum" \
  -d amount=0.005 -d fromAddress="$WALLET" -d toAddress="$WALLET" > quote.json
curl -s -X POST "$BASE/orders" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \
  -d "$(jq -c '{order: .order}' quote.json)" > placed.json
TX_HASH=$(jq -r .transaction.simulatedHash placed.json)   # live: send .transaction from the wallet, use its hash
curl -s -X POST "$BASE/orders/submit" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \
  -d "$(jq -c --arg tx "$TX_HASH" '.next.body + {txHash: $tx}' placed.json)"
```

```ts
const headers = { 'x-maxy-key': KEY, 'content-type': 'application/json' };
const q = new URLSearchParams({ from: 'ETH on base', to: 'ETH on arbitrum', amount: '0.005', fromAddress: account.address, toAddress: account.address });
const quote = await fetch(`${BASE}/quote?${q}`, { headers }).then((r) => r.json());
const placed = await fetch(`${BASE}/orders`, { method: 'POST', headers, body: JSON.stringify({ order: quote.order }) }).then((r) => r.json());

const tx = placed.transaction;
const txHash = tx.simulated ? tx.simulatedHash : await walletClient.sendTransaction({ to: tx.to, data: tx.data, value: BigInt(tx.value) });
await fetch(`${BASE}/orders/submit`, { method: 'POST', headers, body: JSON.stringify({ ...placed.next.body, txHash }) });
```

```python
headers = {"x-maxy-key": KEY}
quote = requests.get(f"{BASE}/quote", headers=headers, params={
    "from": "ETH on base", "to": "ETH on arbitrum", "amount": "0.005", "fromAddress": account.address, "toAddress": account.address,
}).json()
placed = requests.post(f"{BASE}/orders", headers=headers, json={"order": quote["order"]}).json()

tx = placed["transaction"]
tx_hash = tx["simulatedHash"] if tx.get("simulated") else your_wallet_sends(tx)
requests.post(f"{BASE}/orders/submit", headers=headers, json={**placed["next"]["body"], "txHash": tx_hash})
```

A token, unlike ETH, can add an `approve` step first: follow `steps` in order. Track with `GET /status?orderId=…&chainId=8453&toChainId=42161&route=cross-evm`. The states are the same, and `failed` can happen here. A pair with no route answers `unsupported_route`: pick from `GET /pairs`.

---
Source: https://maxy.co/docs/other-coins (Maxy Docs › Swaps › Routes)
