HTTP/1.1 402 PAYMENT REQUIRED agent402.base.eth · BASE · SOLANA · POLYGON · ARBITRUM · ROBINHOOD · USDC · USDG

Onchain analyst (SQL over Base)

Ask Base anything in one paid call: your SQL runs against Coinbase's indexed, DECODED chain data (events with parsed parameters, transactions, blocks, user-ops) with the live schema alongside — no indexer, no RPC archaeology.

When to use this pack

You need an answer that lives on-chain — 'how many wallets touched this contract this week', 'what did this address settle today', 'top USDC recipients yesterday' — and writing an indexer or paging through explorer HTML is absurd for one question. This pack runs your read-only ClickHouse-dialect SQL against base.events / base.transactions / base.blocks and returns the schema document in the same envelope, so a follow-up query can be written without a second discovery call. This is the same data path that powers the public x402 Economy Observatory at /x402-economy.

Tools in this pack

Workflow

  1. Read the schema step first (onchain-sql-schema, no input): base.events is the workhorse — decoded logs with event_name, address, transaction_hash, block_timestamp, and a parameters map you can address as parameters['from']. Cast Variant values with toString()/toUInt256OrZero() before comparing or summing.
  2. Write SELECT-only SQL (WITH … SELECT is fine) against the tables you found. ALWAYS bound by block_timestamp (e.g. >= now() - INTERVAL 7 DAY) — the caps are 50k rows / 30s / 100GB read, and an unbounded scan of base.events will hit them. Joins are limited to 12; prefer transaction_hash IN (subquery) shapes over raw JOINs.
  3. Run it through the onchain-sql step. If the result is empty, suspect the WHERE before the data: addresses in base.events are FixedString(42) lowercase — compare against lower('0x…'). If it errors with a budget/timeout message, narrow the time window first, then the column list.
  4. Iterate: the pack is cheap enough to run several times while you refine. For repeated dashboards pass cacheSeconds (up to 900) so identical queries within the window are served from cache without re-scanning.
  5. The pack's final step runs stats-summary over the first numeric column of your result set — count, sum, mean, median, stddev, quartiles in one shot. For a time series (daily counts, per-block values) that's the distribution picture without a second query; for a single-row aggregate it's a no-op you can ignore.

Run it in Claude

claude mcp add agent402 -s user -- npx -y agent402-mcp@latest

Then paste this prompt into Claude:

Answer a question with SQL over Base using Agent402's onchain-analyst pack. Warm-up: run SELECT COUNT(*) AS blocks FROM base.blocks WHERE block_number > 32000000 to prove the pipe. Then the real question — 'How many USDC transfers settled on Base in the last 24 hours?': (1) read the schema from the pack's schema step, (2) write SELECT COUNT(*) AS transfers FROM base.events WHERE address = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' AND event_name = 'Transfer' AND block_timestamp >= now() - INTERVAL 1 DAY, (3) run it via the sql step and report the count. Keep every query SELECT-only and time-bounded.

← All skill packs