Thegraph

Thegraph makes blockchain data queryable and supports streaming data pipelines

Thegraph is a blockchain data protocol that turns chain records into queryable APIs and processed streams. Subgraphs organize selected contract activity into entities that applications retrieve through GraphQL. Substreams transform historical and incoming blocks for data pipelines. The ecosystem also includes ready-made token APIs and tools for SQL analysis and liquidity simulation. Its decentralized network coordinates indexing and query services through GRT, while individual products have their own data coverage and access requirements.

Indexed records give applications usable histories

Indexing processes blockchain activity into stored records, letting applications retrieve contract histories and relationships without rebuilding that information for every request. A Subgraph's manifest selects the network, contracts, and events that it follows. Mapping code turns those inputs into persistent entities. Graph Node stores the entities and serves their query interface. Applications can then request selected fields, filter records, and order collections. This supports activity views, governance interfaces, and protocol analytics. The mapping determines what each record means, so an API response reflects the Subgraph's definitions and covered data.

An entity is a stored data object. Its schema defines the available fields and relationships that applications can request through GraphQL.

Data interfaces and their compatibility boundaries

The available components differ in their data interfaces and coverage requirements, with custom APIs, processed streams, token endpoints, SQL datasets, and liquidity state addressing different integration needs. Several components can work together. Graph Node runs Subgraph indexing, while Firehose can supply blockchain data to processing systems.

Table: Data interfaces and their compatibility boundaries
Component Primary job Interface and data scope
Subgraphs Custom indexed application APIs GraphQL entities from manifest-selected contracts and a supported network
Substreams Historical and live data processing Module output for a matching chain provider and downstream integration
Token API Ready-made token and wallet data REST endpoints with their own token, network, and history coverage
Amp Blockchain dataset analysis SQL queries over available blockchain datasets
Tycho Liquidity state and swap simulation Stored snapshots and streamed updates for integrated protocols
Graph Node Operate Subgraph indexing and query serving GraphQL with configured chain adapters and data endpoints
Firehose Extract and deliver blockchain records Binary block streams for chains with a Firehose integration
Shared dependency Matching data coverage Support must cover the chain and required records or format

Token API supplies standardized records such as balances, transfers, holders, and token activity. It can fit an application whose requirements match those endpoints, without a custom indexing definition. A specialized contract relationship may require a custom API or processing package. Chain support also belongs to the particular product and provider. Support in a streaming service doesn't automatically establish support in a hosted Subgraph endpoint.

Diagram: Thegraph - Data interfaces and their compatibility boundaries

View full-size image


Subgraph Studio separates testing from network publication

Subgraph Studio provides a staging environment for building and testing custom APIs, while Graph Explorer helps locate published Subgraphs and inspect their query interfaces. Consumers can query an existing Subgraph without developing their own. A Studio deployment and a network publication represent different states. Studio's development endpoint has rate limits and targets testing. Publication registers a Subgraph for discovery by Indexers; it doesn't alone establish that an Indexer has synchronized its data. Production access requires the relevant deployment to be indexed and available.

Substreams connects processed blocks to downstream storage

Substreams applies reusable processing modules to blockchain data, supporting historical backfills and continuing streams that can feed an application's storage or processing system. Substreams executes data transformations in WebAssembly modules. Developers commonly write these modules in Rust and combine them into packages. Parallel execution accelerates suitable historical processing; throughput still reflects the package and underlying data service. Firehose uses file-based extraction and binary streams to deliver blockchain records. It provides an input layer that processing tools can use where the chain integration supports it.

Thegraph: Substreams connects processed blocks to downstream storage

View full-size image

A sink sends module output to a destination such as a SQL database, a file, or a messaging system. Hosted Sinks provide managed deployments, while a self-managed sink gives control over its operation. Compatibility requires a suitable chain endpoint and an integration that understands the package's output. If no ready-made sink matches the destination, a custom consumer can handle the stream. Fork handling and reconnection also matter: the consumer must preserve the provider's data semantics when maintaining downstream state.

SQL datasets and liquidity simulation extend the data tools

Amp adds SQL-based blockchain datasets, and Tycho supplies liquidity state that supports protocol simulation, extending the ecosystem beyond custom GraphQL APIs and general data streams. Amp supports cloud and on-premises deployments for analysis of its available datasets. Tycho combines stored snapshots with streamed updates to reconstruct supported protocol state. Its simulation tools can calculate spot prices and quote swaps for integrated protocols. Dataset coverage controls SQL analysis, while protocol integrations control liquidity modeling. A simulated quote doesn't establish a transaction's final execution price.

What does GRT do in the network?

GRT is the network's utility token for staking, payments, and participant rewards, connecting indexed data provision with economic incentives for the operators that supply it. An API key identifies a consumer's access, while GRT supports the network's economic relationships.

Thegraph: What does GRT do in the network? - illustration

View full-size image

Indexers stake GRT to provide indexing and query-processing services. They operate the infrastructure that synchronizes Subgraphs and answers requests. Query fees compensate query serving, while indexing rewards support indexing activity. Incorrect indexing or query responses can expose an Indexer's own stake to slashing through the protocol's dispute rules. Those penalties have service-specific conditions.

Delegators commit GRT to an Indexer and share rewards under the applicable service's terms. Reward sharing depends on the Indexer's activity and configured cuts; a quoted cut isn't a fixed yield. The GRT being undelegated stops earning rewards and can't be withdrawn until the service's thawing period ends. Graph Horizon makes delegation specific to an Indexer and a data service. SubgraphService currently leaves delegated-stake slashing disabled, although Horizon supports the capability for future service configurations.

Curators signal GRT toward Subgraphs and earn a share of their query fees. Signal helps Indexers assess demand; it doesn't certify the accuracy of a mapping.

Graph Horizon separates shared staking and payment mechanisms from individual data-service implementations. SubgraphService supplies the rules for Subgraph indexing and queries. This architecture supports additional service designs. A streaming provider or hosted API can have its own authentication, billing, and operating arrangements. The relevant implementation determines which network mechanisms apply.

Query charges belong to the access service

Query volume, request complexity, and the gateway's billing model shape what an application pays, while the costs of indexing and keeping a Subgraph fresh belong to a separate activity. Gateways find suitable Indexers, route requests, and handle payment arrangements for consumers. Their operators can offer usage-based billing, subscriptions, or other plans. The underlying Indexer sets query cost models, so a consumer plan doesn't describe every network payment. Streaming services may meter processed blocks and delivered data rather than count GraphQL requests.

API-key access lets an application use the selected gateway's account and billing arrangement. The x402 Subgraph gateway option accepts per-query payments in USDC on Base, while network settlement with Indexers uses GRT. That separates the consumer's payment asset from the network's settlement asset. Availability depends on the gateway's configuration. Included usage, spending limits, and payment methods also belong to the selected service; they aren't universal protocol constants.

Freshness and credentials affect the usable data

A Subgraph response describes the state that its serving deployment has indexed, so an application's latest visible records can lag behind the chain's newest block. The GraphQL _meta field exposes indexed-block information, the deployment identifier, and an indexing-error flag. Those fields help interpret a response's coverage. A successful HTTP request doesn't establish that indexing has reached chain head or that a mapping captures every relevant event. Recent chain reorganizations can also change records before finality, affecting applications that act on immediately available data.

Browser code exposes any query key that it contains. Subgraph query keys can support domain and Subgraph restrictions, limiting their intended use. Streaming authentication tokens need private storage and shouldn't appear in browser bundles or public repositories. Self-hosting Graph Node adds responsibility for blockchain connections, database availability, and access controls. Administrative interfaces and database services must remain private. A public query endpoint needs an appropriate proxy and protection against abusive requests; operating the software doesn't remove those infrastructure requirements.

Thegraph: what people ask

Does reading a Subgraph require a wallet signature for every query?

An API-key-authenticated Subgraph query doesn't require a wallet signature for each request. It reads indexed data through an HTTP interface, with the gateway attributing usage to the key. Wallet signatures belong to separate operations such as publishing a Subgraph or authorizing on-chain payments. An x402-enabled endpoint uses its own payment authorization flow.

Is GRT's token supply permanently fixed?

GRT's supply isn't permanently fixed because issuance adds tokens while burning removes them. Initial supply, total supply, and circulating supply describe different quantities. Governance can change issuance parameters, so a launch-era rate doesn't establish a permanent rate of growth. Historical token allocations also don't describe how much GRT is liquid today.

Why can a GraphQL client report an invalid JSON response?

A client can report invalid JSON when an endpoint or intermediary returns HTML or plain text. An HTTP error page can cause this failure before the client parses a GraphQL response. The response status and content type help distinguish an endpoint problem from a query error. The parsing message alone doesn't identify an indexing failure.

Can a Subgraph process files stored outside a blockchain?

A Subgraph can process off-chain files through file data sources for IPFS and Arweave. File handlers write their own entities and can't access or update chain-based entities directly. The schema can relate those separate records. This functionality requires compatible tooling and configuration; it doesn't provide arbitrary HTTP access from a mapping.

When can a query retrieve a Subgraph's earlier state?

A historical query can select a block number or hash when the serving deployment retains the required indexed state. The requested block must fall within that deployment's available history. Pruning can remove older queryable state. Queries involving an unfinalized block can also face reorganization-related limitations, so a block hash doesn't eliminate every consistency condition.

Which network matters when a wallet displays GRT?

The wallet must recognize GRT's contract on the network that holds the tokens. GRT has distinct deployments on Ethereum and Arbitrum One, and an Ethereum ERC-20 balance doesn't automatically appear as an Arbitrum balance. A matching ticker isn't enough to identify the deployment. Changing a wallet's network display doesn't move tokens between chains.

How long does a newly deployed Subgraph take to synchronize?

Synchronization time varies with the history that the Subgraph covers and the resources that process it. A longer indexed history, expensive mapping handlers, and slower blockchain data access can extend the backfill. Indexing progress establishes how far the deployment has reached. Deployment acceptance and network publication don't establish that historical synchronization has finished.

Can another wallet take ownership of a published Subgraph?

A published Subgraph's owner can transfer it by sending the corresponding NFT, a non-fungible token that identifies the owner. The recipient takes ownership, and the previous owner loses Studio management access for that Subgraph. The transfer changes control of the published API definition, not ownership of the smart contracts that it indexes.
Updated on