indexing

Design smart contract events and deploy subgraphs to query historical onchain data.

10|1|Updated Mar 19, 2025
One-click install
npx skills add https://github.com/ObolNetwork/obol-stack --skill indexing-obolnetwork
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: indexing
Source: https://github.com/ObolNetwork/obol-stack/tree/main/internal/embed/skills/indexing
Command: npx skills add https://github.com/ObolNetwork/obol-stack --skill indexing-obolnetwork

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenges of reading historical onchain data, preventing common pitfalls like inefficient RPC calls or block scanning, and guiding users towards effective indexing solutions.

Core Features & Use Cases

  • Understanding Onchain Data Limitations: Explains why direct RPC calls for historical data are problematic and why looping through blocks is inefficient.
  • Leveraging Indexing Solutions: Introduces The Graph as a primary tool for creating queryable GraphQL APIs from smart contract events.
  • Event-Driven Design: Emphasizes designing smart contracts with events as the primary mechanism for offchain data consumption.
  • Alternative Solutions: Compares and contrasts various indexing methods like Dune Analytics, provider APIs, and direct RPC for different use cases.

Quick Start

Use the indexing skill to understand how to query historical onchain data using The Graph.

Frequently Asked Questions about indexing

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

FAQPage Schema
What is the best way to query historical onchain data from smart contracts?

Indexing solutions like The Graph provide the best way to query historical onchain data by creating queryable GraphQL APIs from smart contract events. This approach prevents the severe inefficiencies of direct RPC calls or looping through blockchain blocks for data retrieval.

Why does looping through blocks via RPC for historical data fail?

Looping through blocks via RPC fails because it is highly inefficient for reading historical onchain data. Direct RPC calls are not designed for bulk historical queries, making dedicated indexing solutions necessary for scalable dApp data retrieval and analytics.

How do I design smart contracts for efficient offchain data consumption?

Design smart contracts using an event-driven architecture, treating events as the primary mechanism for offchain data consumption. This allows indexing protocols like The Graph to map smart contract events efficiently to a queryable schema for dApp development.

How do I deploy a subgraph to query onchain data efficiently?

Deploy a subgraph by defining a GraphQL schema and mapping smart contract events to establish a queryable API. This indexing process transforms raw onchain data into structured GraphQL endpoints, enabling efficient data retrieval without direct RPC block scanning.

How does The Graph compare to Dune Analytics for onchain data indexing?

The Graph builds queryable GraphQL APIs via subgraph deployment for dApp integration, while Dune Analytics provides alternative indexing for blockchain analytics. Direct provider APIs and RPC methods are also compared for different specific data retrieval use cases.

When should I not use direct RPC calls for blockchain data?

You should not use direct RPC calls when querying historical onchain data for dApps, as block scanning is highly inefficient. Instead, use an indexing solution to map smart contract events into a GraphQL schema for performant data retrieval.