.jpg)
.jpg)
Case Study: How The Graph's Substreams and Token API Made Multi-Chain Indexing 24x Faster
Sequential Processing Creates Multi-Chain Bottlenecks
Building multi-chain applications requires unified access to token data across various blockchains. Typically, traditional RPC-based indexing processes blocks sequentially, creating fundamental shortcomings:
- Sequential processing cannot keep pace with demanding data needs
- Complex balance changes in DeFi protocols get missed or calculated incorrectly
- Each chain needs separate infrastructure, multiplying costs
These constraints made building an optimal Token API challenging with traditional approaches, so The Graph built a different approach using Substreams.
Solution: Substreams Makes a Better Token API Possible
The Graph’s Token API is a unified REST API that serves token, balance, price, and NFT data across Ethereum, BNB Smart Chain, Polygon, Optimism, Arbitrum, Base, Unichain, Avalanche, and Solana. Powered by Substreams, Token API delivers:
- Wallet Balance Data: Current and historical token balances with accurate DeFi position tracking
- Transaction Data: Token transfers with full context and cross-chain tracking
- Price Data: OHLC feeds with historical data and real-time updates
- NFT Data: ERC-721/1155 ownership records, metadata, and transfer history
The system also integrates AI using a Model Context Protocol (MCP) server connecting users’ applications directly to the product’s backend. The API provides this data instantly across all supported chains.
Why Substreams Powers Token API’s Performance
The Graph’s Token API achieves its remarkable performance because Substreams fundamentally transforms how blockchain data is indexed. Instead of adapting traditional indexing methods, Token API leverages Substreams' core innovations:
Parallel Processing: Indexing jobs are divided into 1k block segments, enabling the simultaneous indexing of thousands of blocks per second. This parallel architecture is why Token API can convert hours of processing into just minutes of work.
Composable Modules: Transfer, balance, price, and NFT modules are built as independent Substreams components. Each module develops independently, caches outputs, and eliminates redundancy.
Chain-Agnostic Design: Firehose provides a flat file format usable across chains, with one unified protobuf schema. The Token API ingests data from all supported blockchains: Ethereum, Arbitrum, and Polygon are processed and standardized into the schema for easy consumption.
Redundant Balance Tracking: Substreams supports batched RPC lookups outside of its own stateful balances to accurately capture every DeFi balance update, from flash loans to multi-step swaps. Everything gets tracked.
Intelligent Caching: After processing data, downstream modules instantly reuse it. Processing Ethereum's token transfers once allows new modules to use the cached data, resulting in major speed boosts. Hours of processing don’t go to waste.
Result: Substreams Makes 24x Faster Performance Real
The performance gains from building Token API on Substreams are transformative:
- Ethereum: Full blockchain sync reduced from 3 days to 10 hours
- Arbitrum One: Complete history processed in 15 hours instead of 15 days
These improvements represent a 2300% speed increase for Arbitrum and over 600% for Ethereum. Caching and modular design compound these gains, making queries once considered impossible now practical.
AI-Powered Data Access
Through a Model Context Protocol (MCP server), the Token API enables natural language queries and millisecond aggregations. Developers can instantly:
- Pull wallet balances across chains
- Retrieve years of NFT ownership data
- Stream real-time token prices
The Developer Advantage
- No infrastructure, no debugging
- Unified queries across nine chains and counting
- Accurate balance tracking for even the most complex DeFi positions
- AI-ready with natural language query support
Why It Matters
Token API demonstrates how Substreams doesn't just make indexing faster. It enables entirely new categories of blockchain applications. By building on Substreams, Token API delivers:
- Real-time accuracy that sequential processing cannot achieve
- Cross-chain interoperability through unified architecture
- Cost cuts that make comprehensive indexing affordable
Every architectural decision in Token API leverages Substreams to deliver this massive performance improvement. The result: easier DeFi dashboards, AI trading bots, gaming platforms, and analytics tools can now access blockchain data in minutes instead of hours.
Substreams made Token API possible. Token API makes blockchain data practical.
Start querying today. Build faster applications with zero infrastructure at
About The Graph
is the leading indexing and query protocol powering the decentralized internet. Since launching in 2018, it has empowered tens of thousands of developers to effortlessly build and leverage across countless blockchains, including Ethereum, Solana, Arbitrum, Optimism, Base, Polygon, Celo, Soneium, and Avalanche. With powerful tools like Substreams and Token API, The Graph delivers high-performance, real-time access to onchain data. From low-latency indexing to rapid token data, it serves as the premier solution for building composable, data drive dapps.
Discover more about how The Graph is shaping the future of decentralized physical infrastructure networks (DePIN) and stay connected with the community. Follow The Graph on , , , , , and . Join the community on The Graph’s , join technical discussions on The Graph’s .
oversees The Graph Network. , , , , and are seven of the many organizations within The Graph ecosystem.