onchain_query
PRIMARY tool for indexed on-chain stats/activity/totals — prefer this over raw RPC for chain data. Each op is a backend-agnostic intent: the query gateway selects the most accurate live source per field (indexed DB / pre-aggregated metrics / Data API), stamps every field (sources), and flags any caveat (warnings) — relay warnings to the user, never present a flagged value as exact. Pick an op and pass its params; chainId is an allowlisted EVM chain (43114 C-Chain, 43113 Fuji, + L1s). Lookback: hour-based ops (chainStatsRecent/chainActivity/addressActivity) max 720h (30 days); day-based ops (chainStatsSeries/contractStats/chainGasTotal/protocolRanking/contractGasFlow/topUnknownContracts) max 365 days — use a day-based op for windows over 30 days. Ops: chainStatsRecent {chainId, hours≤720} — tx count/gas/fees/active senders/avg gas price over the last N hours; chainStatsSeries {chainId, days≤365, bucket: hour|day|week|month} — bucketed time-series of the same; addressActivity {chainId, address, hours≤720, limit≤100} — tx count + recent sample for an address in a window; chainActivity {chainId, hours≤720, limit≤100} — tx count + recent sample chain-wide in a window; contractStats {chainId, contract, days≤365} — tx/unique-sender/gas totals for a contract; protocolRanking {chainId, contracts[≤25], days≤365, orderBy: txCount|gasUsed|uniqueSenders|feesPaidAvax, dir: asc|desc, limit≤100} — rank a set of contracts; contractGasFlow {chainId, contract, days≤365, limit≤100} — gas received/given per counterparty; topUnknownContracts {chainId, exclude[≤25], days≤365, limit≤100} — top contracts by gas excluding a set; chainGasTotal {chainId, days≤365} OR {chainId, fromDate, toDate} — total tx/gas/fees over N days or a YYYY-MM-DD range (≤365d). Note: C-Chain gasUsed is gas-target-regulated → ~stable day-to-day even as txCount varies (expected, not a bug).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | Yes | The query operation | |
| params | Yes | Op-specific parameters (see description); validated server-side. |