indexing

Query historical onchain data using events, The Graph subgraphs, and indexing patterns.

Updated Sep 9, 2026
One-click install
npx skills add https://github.com/m-faran/genie-markets --skill indexing-m-faran
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: indexing
Source: https://github.com/m-faran/genie-markets/tree/main/.agent/skills/ethskills/indexing
Command: npx skills add https://github.com/m-faran/genie-markets --skill indexing-m-faran

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Reading historical blockchain data is not possible with plain RPC calls — eth_call only reads current state, and scanning millions of blocks with eth_getLogs times out or gets rate-limited. This Skill teaches the correct patterns for querying onchain history using events, indexers, and The Graph. ## Core Features & Use Cases - Event-First Contract Design: Guidance on emitting and indexing Solidity events so frontends, indexers, and explorers can query every state change. - The Graph Subgraphs: End-to-end walkthrough of schema definition, mapping handlers, deployment, and GraphQL queries for historical data. - Alternative Indexers & APIs: Comparison of Dune Analytics, Alchemy/QuickNode APIs, Ponder, and direct RPC, plus Multicall batching and WebSocket subscriptions for real-time updates. - Use Case: You are building an NFT marketplace frontend that needs an activity feed and ownership history. Use this Skill to design events, deploy a subgraph, and query transfers via GraphQL instead of scanning blocks. ## Quick Start Ask the AI to explain how to index and query historical events from your smart contract using The Graph instead of looping through blocks.

Frequently Asked Questions about indexing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query historical blockchain events without scanning blocks?▼

Use an indexer like The Graph that has already processed every block. Define a subgraph with a schema and event mappings, deploy it, and query the indexed data through a GraphQL API instead of calling eth_getLogs across millions of blocks.

What is The Graph and when should I use it?▼

The Graph is a decentralized indexing protocol that turns contract events into a queryable GraphQL API. Use it whenever your dApp needs historical data such as activity feeds, leaderboards, or analytics that would require scanning more than roughly 10,000 blocks.

The Graph vs Dune Analytics vs Alchemy APIs for onchain data?▼

The Graph suits production dApp backends with custom GraphQL APIs. Dune Analytics is best for SQL-based dashboards and ad-hoc analysis, not app backends. Alchemy APIs like getTokenBalances and getAssetTransfers are fastest for common queries but are centralized.

Can I read historical contract state with eth_call?▼

No, eth_call reads current state only. Reading state at a historical block requires an archive node, which is expensive and slow. For historical data, emit events from your contract and use an indexer to query them.

Why does my eth_getLogs query time out or get rate-limited?▼

Scanning large block ranges with eth_getLogs is O(n) and quickly hits RPC timeouts, rate limits, or credit costs. Limit direct log queries to a few thousand recent blocks, and use a subgraph or provider API for anything historical or high-volume.

How do I get real-time updates for new contract events?▼

Subscribe via WebSocket using viem's watchContractEvent with a wss transport. This streams new event logs as they occur, which is suitable for live monitoring rather than historical queries.