POST /api/onchain-sqlRun 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.
| Field | Type | Description |
|---|---|---|
sql * | string | Read-only SELECT (ClickHouse dialect, max 10,000 chars). Tables: base.events, base.transactions, base.blocks, base.encoded_logs, base.decoded_user_operations, base.transaction_attributions, base_sepolia.*, solana.instructions, hyperevm.events |
cacheSeconds | number | Accept cached results up to this old (max 900). Cheaper + faster for repeated analytics. |
{
"rows": [
{
"txs": 123456
}
],
"rowCount": 1,
"note": "Result rows exactly as returned by the SQL engine."
}
curl -i -X POST https://agent402.tools/api/onchain-sql \
-H "Content-Type: application/json" \
-d '{"sql":"SELECT COUNT(*) AS txs FROM base.transactions WHERE block_number > 0 LIMIT 1"}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/onchain-sql", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"sql": "SELECT COUNT(*) AS txs FROM base.transactions WHERE block_number > 0 LIMIT 1"
}),
});
GET /api/wallet-balancesAll token balances for any address in one call, from Coinbase's indexed data API — ERC-20 + native on EVM, SPL on Solana…
POST /api/testnet-fundFund any address with testnet money via the Coinbase faucet — USDC (1) or ETH (0.0001) on Base Sepolia, USDC (1) or SOL …
POST /api/onramp-linkGenerate a single-use Coinbase Onramp URL that lets a human fund any wallet with a card or Apple Pay — the fastest way t…