Find something... ⌘K

SDK / Testing

Test your integration

Run your SDK code against the sandbox, force every outcome your product must handle, and know what the sandbox cannot show. It is for developers getting an integration ready for its first live order.

Use a test key

The SDK needs no other change: a test key (mxk_test_…) runs every call in the sandbox, the same API with nothing real behind it. maxy.sandbox reads true, and the client can reach only the sandbox API. Get a key with no sign-up:

curl Copy
curl -s -X POST https://openapi.maxy.co/v1/sandbox/keys | jq -r .secretKey

Put it in MAXY_API_KEY, and keep it: one address gets 5 test keys an hour. A test key gives 120 calls a minute and 50 open orders, and keeps orders for 7 days.

Force each outcome

This page runs the scenarios through the SDK; over HTTP, each one and what it answers is on Test scenarios. Pass scenario to a quote, a flow helper or swap.execute, and the order walks there by itself. A live key ignores it. This runs each outcome a buy must handle through buyBtcWithEvm, with a throwaway wallet:

TypeScript Copy
import { createMaxyClient, isMaxyError } from 'maxy-labs/core'; import { buyBtcWithEvm } from 'maxy-labs/evm'; import { createWalletClient, http } from 'viem'; import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; import { base } from 'viem/chains'; const maxy = createMaxyClient(); // reads MAXY_API_KEY const wallet = createWalletClient({ account: privateKeyToAccount(generatePrivateKey()), chain: base, transport: http() }); const recipient = 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4'; for (const scenario of ['success', 'refund_available', 'expired_quote', 'price_moved', 'over_cap', 'too_small', 'unfillable', 'simulation_fails']) { try { const done = await buyBtcWithEvm({ client: maxy, wallet, from: 'ETH on base', amount: '0.001', recipient, scenario }); console.log(scenario, done.order.state); } catch (e) { console.log(scenario, isMaxyError(e) ? `${e.name} ${e.code}` : e); } }
scenarioThe SDK gives
successcompleted, with a sandbox btcTxId
refund_availablerefundable: the helper stops there, for the user to act
expired_quoteQuoteExpiredError, quote_expired
price_movedQuoteExpiredError, quote_mismatch
over_capAmountOutOfRangeError, order_cap_exceeded
too_smallAmountOutOfRangeError, amount_out_of_range
unfillableUnfillableError, insufficient_liquidity
simulation_failsChainError, tx_reverted: the escrow is never sent

sandboxControls.scenarios() lists every scenario with a line on what it does, including order_expired, order_failed, order_cancelled, underpaid for a sell, rate_limited and webhook_replay, which sends each event twice. The words to show for each: Signature screen.

Skip the wait

An order starts when you submit it, or by itself 30 seconds after you place it, and a success walks to completed in about 20 seconds. sandboxControls.advance moves it on now: to the state you name, or to the next one.

TypeScript Copy
const moved = await maxy.sandboxControls.advance(orderId, { to: 'completed' }); console.log(moved.state, moved.btcTxId); // completed 53414e44424f58…

To test your code that skips Maxy when it is degraded, read GET /health?scenario=degraded.

Without a network

For unit tests, maxy-labs/testing answers with the API's own envelopes and no network: a mock fetch, one fixture per error code, and a simulator that walks an order through any states. It plugs into Mock Service Worker too: Flow helpers.

What the sandbox cannot show

Not in the sandboxWhat it does instead
Real transactionsNothing is broadcast. A transaction goes to the zero address with gas "1"; its simulatedHash stands in for the hash
Balances and allowancesNot read. Force issues.balance or issues.allowance with insufficient_funds or needs_approval
BitcoinTxids and order ids start with 53414e44424f58, "SANDBOX" in hex. Deposit addresses are testnet ones
Taproot on SOL buysOnly bc1q… receives in the sandbox; live, bc1p… does too
The $10 sell minimumNot enforced, so a smaller sell completes. Live, POST /orders refuses it
Loans and sign-inThe full client answers sandbox_refused for borrow and auth calls
Other servicesA test-key client reaches the sandbox API and nothing else: no RPC, bridge or solver

A real order id read with a test key answers not_found. When your code passes, go to mainnet with one buy with $5 of USDC and one with 0.002 ETH, then work through the launch checklist. Do not load-test production.