How to query smart contract data for building on the blockchain

Querying blockchain data via RPC is slow and unscalable. Learn why subgraphs are the modern solution and how Ormi’s 0xgraph delivers real-time, high-performance indexing for smart contract apps across 70+ chains.

How to query smart contract data for building on the blockchain

If you’re building an on-chain application, one of the first questions you’ll face is: how do I access blockchain data efficiently?

Whether you’re developing a wallet, a DeFi trading protocol, an NFT game, a distributed workflow system, or AI agents, your application needs fast, accurate, and reliable access to on-chain data. Without it, how can you make decisions, or show users the state of their account? The problem is, blockchain nodes (via JSON-RPC) weren’t designed for fast data retrieval.

How most developers start out

JSON-RPC 

Most developers start here. JSON-RPC is the default protocol for writing to and reading from blockchains. Since blockchains are optimized for writing, using JSON-RPC to read data is slow and cumbersome, even with the use of a good library. 

Strengths

  • Ubiquitous 
  • Good for low-level operations and current state reads

Limitations

  • Not queryable,  no filtering, sorting, or pagination
  • Limited history (unless you pay for archive access)
  • Poor for aggregations or multi-step logic
  • No indexing, no relational structure

Self-indexing

This is already much more complicated. A developer can run a full RPC node, consume and process logs and events, and build an indexing infrastructure using tools like ethers.js or web3.py.

Strengths

  • Fully customizable

Limitations

  • Expensive and time-consuming to maintain
  • Requires archive nodes for full history
  • Difficult to scale

Self-indexing

This is already much more complicated. A developer can run a full RPC node, consume and process logs and events, and build an indexing infrastructure using tools like ethers.js or web3.py.

Strengths

  • Fully customizable

Limitations

  • Expensive and time-consuming to maintain
  • Requires archive nodes for full history
  • Difficult to scale

A more straightforward way: use a Subgraph

If your application is powered by smart contracts, especially ones emitting events, you can use a subgraph. A developer-defined, real-time indexer that tracks contract activity and exposes it via a GraphQL API.

Subgraphs let you define:

  • Which contracts to track
  • Which events to index
  • How to transform those events into queryable entities
  • What the query schema should look like

Why Subgraphs are made for easy on-chain queries

Feature RPC Node Subgraph
Can query historical events
Support filters/sorting/pagination
Automatically updates with new blocks
Custom data schema
Scales with app logic

Subgraphs are the OLAP layer of blockchain. They let you analyze and aggregate data in ways raw node access cannot.

Subgraphs are ideal for:

  • Tracking token or NFT activity
  • Powering leaderboards, analytics, and UIs
  • Running real-time bots based on event streams
  • AI agent automation
  • DeFi position rebalancing

Introducing 0xGraph by Ormi

Ormi provides a drop-in, high-performance subgraph host called 0xGraph that supports all EVM-compatible contracts.

With 0xgraph, you get:

  • 5× faster indexing performance compared to legacy subgraph solutions
  • 71% faster query performance
  • Multi-chain access across any chain Ormi supports, including L2s 
  • To migrate existing subgraphs instantly. Ormi is 100% compatible with The Graph’s subgraph spec

Unlike RPC-based approaches, 0xgraph provides:

  • Sub-30 ms query latency at 1,000+ RPS
  • Real-time data indexing and zero throttling

When should you use Subgraphs

If you:

  • Need to show real-time dynamic events (like user actions, swaps, votes)
  • Need to run queries across time or multiple contracts
  • Want structured, queryable, developer-friendly data

Then, subgraphs are your best bet.

Conclusion

Accessing blockchain data isn’t just about calling an RPC node.

If you want performance, structure, and scale, especially for applications built on smart contracts, you need that data indexed.

Subgraphs are the cleanest, most flexible way to do it.

And Ormi’s 0xgraph offers the fastest, most reliable subgraph platform available, with full support for smart contracts across 70+ chains and real-time production workloads.

👉 Start building with real-time data: https://app.ormilabs.com/

About Ormi

Ormi is the next-generation data layer for Web3, purpose-built for real-time, high-throughput applications like DeFi, gaming, wallets, and on-chain infrastructure. Its hybrid architecture ensures sub-30ms latency and up to 4,000 RPS for live subgraph indexing, sub-10ms responses across 100+ API schemas, and a powerful SQL engine for historical and AI-ready data.

With 99.9% uptime and deployments across ecosystems representing $50B+ in TVL and $100B+ in annual transaction volume, Ormi is trusted to power the most demanding production environments without throttling or delay.