# Buy an AcePilot answer with x402 (Base mainnet, USDC)

AcePilot sells historical on-chain range evidence for Aero (ex-Aerodrome) Slipstream concentrated-liquidity pools on Base. Every paid route is an HTTP `GET` that answers `402 Payment Required` until a USDC payment on Base is attached (x402 v2, `exact` scheme). This page is the shortest path from zero to a paid Q1 answer. It is data and analytics only, not advice.

- Pay to: `roguelab.base.eth` (`0x08BA157aFc403fc5D41a9772778966D37b472415`), asset USDC `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`, network `eip155:8453`.
- Q1 (range evidence for one pool): `GET https://aeroacepilot.xyz/v1/q1?pool=<address>&window_h=168&target=90`, list price 0.04 USDC. Always trust the amount in the 402 response; it is the amount you will be charged.
- Pool addresses: `https://aeroacepilot.xyz/catalogue.json` (`pools[].pool`). `window_h` is 24 to 720 (168 = 7 days), `target` is 80, 90 or 95.
- A refused or stale query returns 4xx or 503 with `charged: false` before any payment is requested.

## 1. See the 402 (curl, no payment)

```bash
POOL=$(curl -s https://aeroacepilot.xyz/catalogue.json | python3 -c 'import json,sys; print(json.load(sys.stdin)["pools"][0]["pool"])')
curl -si "https://aeroacepilot.xyz/v1/q1?pool=$POOL&window_h=168&target=90" | head -n 20
# HTTP/2 402
# payment-required: <base64 JSON: x402Version 2, accepts[amount, asset, network, payTo], resource, extensions>
# link: <https://aeroacepilot.xyz/docs/BUY.md>; rel="service-doc"
# the JSON body repeats the same requirements plus price_usdc and docs fields
```

Decode the requirements: `curl -si ... | grep -i '^payment-required' | cut -d' ' -f2 | base64 -d`.

## 2. Pay and fetch (TypeScript, `@x402/fetch`)

Needs a Base wallet that holds a little USDC (no ETH needed: the payment is a signed EIP-3009 authorization and the facilitator pays gas). Keep the key in an environment variable.

```bash
npm install @x402/fetch @x402/evm viem
```

```typescript
import { wrapFetchWithPaymentFromConfig, decodePaymentResponseHeader } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }], // Base mainnet
});

const base = "https://aeroacepilot.xyz";
const { pools } = await (await fetch(`${base}/catalogue.json`)).json();
const url = `${base}/v1/q1?pool=${pools[0].pool}&window_h=168&target=90`;

const res = await fetchWithPayment(url); // 402 -> signs the payment -> retries once
console.log(res.status, await res.json());
const paid = res.headers.get("PAYMENT-RESPONSE");
if (paid) console.log(decodePaymentResponseHeader(paid)); // settlement transaction
```

The answer carries `answer_sha256`; `GET /v1/archive/<answer_sha256>` (free, 30 days) returns the canonical bytes so you can verify it.

## 3. Other routes

The same client pays every route. Prices, parameters and examples are in `https://aeroacepilot.xyz/openapi.json`, `https://aeroacepilot.xyz/llms.txt` and `https://aeroacepilot.xyz/catalogue.json`. Examples: `/v1/check` (0.001, preflight: would this exact request be answered), `/v1/q2`, `/v1/top5`, `/v1/position-yield`, `/v1/open` (0.06 + 0.03 per evidence record, terms in `https://aeroacepilot.xyz/docs/PRICING-TERMS.md`), `/v1/q1-batch` (0.036 per pool, 2 to 10 pools), the data grains under `/v1/grains/` and the analytics routes, including `/v1/il/range` (0.007, historical impermanent loss of your range over 24/72/168 h) and `/v1/watch/position?token_id=<id>` (0.0045, range monitor by position NFT id), `/v1/oor-watch?token_id=<id>` (0.021, out-of-range evidence card), `/v1/fee-or-aero` (0.085, staked vs unstaked side by side), `/v1/wallet-positions?owner=<address>` (0.065, position inventory) `/v1/real-yield` (0.045, fees vs AERO for your own range), `/v1/odds/range-exit` (0.013, empirical exit frequency with a self-test) and `/v1/brief/position?token_id=<id>` (0.033, one citable hash-pinned position brief). Uniswap v3 on Base has three routes, x402 only: `/v1/uni/real-yield` (0.046, fees for your own range from on-chain fee growth), `/v1/uni/migrate?position=<id>` (0.101, your Uniswap v3 position versus the same pair on Aero) and `/v1/uni/oor-watch?token_id=<id>` (0.022, out-of-range evidence card). Prepaid credits are optional: `https://aeroacepilot.xyz/docs/CREDITS-TERMS.md`.
