> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphadvocate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# x402 payments

> Graph Advocate accepts and sends x402 payments on Base.

## Accepting payments

Several routes are x402-gated by `PaymentMiddlewareASGI`:

| Route                                            | Price            | Purpose                                                          |
| ------------------------------------------------ | ---------------- | ---------------------------------------------------------------- |
| [`POST /route`](/route)                          | \$0.01 USDC      | Paid routing query                                               |
| `POST /tip`                                      | \$0.01 USDC      | Voluntary tip jar                                                |
| [`POST /ask`](/ask)                              | \$0.05 USDC      | NL→SQL Q\&A over the 132M-row x402 settlements parquet warehouse |
| [`POST /onchain-x402/address`](/onchain-address) | \$0.01 USDC      | On-chain x402 reputation lookup via the Graph Network subgraph   |
| [`POST /polymarket/pnl-quick`](/polymarket)      | \$0.01 USDC      | Fast Polymarket wallet skill read                                |
| [`POST /polymarket/pnl`](/polymarket)            | \$0.05 USDC      | Full Polymarket wallet dossier                                   |
| [`POST /polymarket/screen`](/polymarket)         | \$0.02 USDC      | Size the room — top holders of a Polymarket market               |
| [`POST /polymarket/risk`](/polymarket)           | \$0.02 USDC      | Ghost-fill counterparty risk on Polymarket                       |
| [`POST /hyperliquid/*`](/hyperliquid)            | $0.01–$0.03 USDC | Hyperliquid trader intelligence (6 endpoints)                    |

All settle via the **CDP facilitator** (`api.cdp.coinbase.com/platform/v2/x402`) on Base. Payments trigger CDP Bazaar indexing automatically on first success.

## Sending payments

Graph Advocate can pay *other* x402-gated agents via the admin endpoint:

```
POST /admin/outreach-pay
Authorization: Bearer <ADMIN_TOKEN>

{
  "target_url": "https://some-agent.example.com/endpoint",
  "message": "Hello from Graph Advocate",
  "max_usdc": "0.05"
}
```

Uses `x402Client` + `EthAccountSigner` under the hood (`ExactEvmScheme` + `UptoEvmClientScheme` for both fixed and usage-based pricing). Signs in-memory, never logs the key.

## Wallets

Two wallets, distinct roles:

| Role                                    | Address                                                            | Key location                                                                                                                                                             |
| --------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Identity / owner / outbound spender** | `0x575267eED09c338FAE5716A486A7B58A5749A292` (`graphadvocate.eth`) | `GA_BASE_WALLET_PK` on Railway. Owns ERC-8004 agent #41034 (Base) and #734 (Arbitrum). Signs outbound x402 calls from `x402_outreach.py`. Signs in-memory, never logged. |
| **Incoming x402 payTo**                 | `0x0FF5A6ecef783BBA35463ec2F8403B9B5e9e7C86`                       | **Ampersend smart account** — no EOA private key, controlled via Ampersend. Default for `X402_PAY_TO`.                                                                   |

Earnings (Ampersend) are isolated from the identity/outreach key so a Railway compromise can't drain incoming revenue. The incoming wallet has no EOA key at all.

> **Note on on-chain `agentWallet`:** the ERC-8004 Identity contract on Base currently records the *identity* wallet (`0x575267…`) as agent #41034's `agentWallet`, not the payTo. Indexers that join 8004 ↔ x402 by `agentWallet` will not attribute revenue correctly. The off-chain [erc8004-registration.json](../erc8004-registration.json) declares the Base payTo via a CAIP-10 `agentWallet` service entry. Updating the on-chain field requires Ampersend to produce an ERC-1271 signature for the new wallet.

## Bazaar discovery

Both `POST /route` and `POST /tip` declare discovery metadata via `declare_discovery_extension(...)` so CDP's Bazaar indexes the endpoints with input/output schemas after the first successful payment.
