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
-
Onchain SQL schema
$0.002
GET /api/onchain-sql-schema
The table + column schema for the onchain-sql tool — every queryable table (base.events, base.transactions, base.blocks, base.decoded_user_operations, base.transaction_attributions, solana.instructions, …) with its columns and types. Fetch once, then write SQL with confidence.
-
Onchain SQL (query Base with SQL)
$0.020
POST /api/onchain-sql
Run read-only SQL against Coinbase's indexed, DECODED blockchain data — base.events (decoded logs with parameters), base.transactions, base.blocks, base.decoded_user_operations, base.transaction_attributions (builder codes), plus solana.instructions and hyperevm.events. ClickHouse-dialect SELECTs, server-side grammar validation, up to 50k rows / 30s / 12 joins. Ask Base anything — token flows, event analytics, gas studies — in one call, no indexer to run.
-
Stats summary
$0.001
POST /api/stats-summary
Compute the full descriptive-stats panel for an array of numbers in one call: count, sum, mean, median, mode, stddev (sample), variance, min, max, range, q1, q3, IQR. Beats calling 12 separate tools when you already have the array in front of you.
Workflow
- 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.
- 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.
- 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.
- 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.
- 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