Subgraph

A subgraph is an open indexing specification that extracts chosen events and state from a blockchain's smart contracts, stores them under a defined schema, and serves the result through a GraphQL API, a design introduced by The Graph protocol.

Share
Subgraph

A subgraph is an open indexing specification that extracts chosen events and state from a blockchain's smart contracts, stores them under a defined schema, and serves the result through a GraphQL API, a design introduced by The Graph protocol. In graph theory the word means a subset of a graph's vertices and edges. That sense is unrelated here.

How it works

A subgraph is defined by three parts. The first is a manifest (subgraph.yaml) that lists the contracts, start blocks and events to watch. The second is a GraphQL schema that describes the entities to store. The third is a set of mapping handlers written in AssemblyScript and compiled to WebAssembly. Software called Graph Node reads each block and runs the matching handler when a listed event fires. It then writes the entity updates to a database that clients query. For example, the Uniswap v3 subgraph turns Swap, Mint and Burn events into Pool, Token and Position entities with running totals for volume and liquidity.

On The Graph's decentralized network, independent indexers stake the GRT token to serve subgraphs. Curators signal GRT on the subgraphs they consider worth indexing, and consumers pay query fees in GRT. Indexers submit a Proof of Indexing that is used in dispute resolution, and their stake can be slashed for incorrect work. The Graph retired its centralized hosted service in 2024. Commercial providers such as Goldsky and Alchemy also run subgraphs written in the same format. As a result, "subgraph" now often refers to the code format regardless of who hosts it.

Why it matters

Many protocol dashboards, front ends and analytics pages draw on subgraphs, so the TVL, volume or position figures an institution sees may come from one. A subgraph captures only what its handlers record, which is mostly emitted events. State changes that emit no event, and contracts missing from the manifest, are absent from the data. The deployer writes the mapping logic, so a bug or an unusual pricing assumption carries into every downstream number. Two subgraphs for the same protocol can therefore report different totals. Indexing can also lag the chain head, and a deterministic handler error can stop syncing at a single block, which leaves the data stale with no obvious warning. For reporting purposes, the usual control is to reconcile subgraph outputs against raw onchain data or an independent indexer.

  • GraphQL
  • Indexer
  • Event log
  • Blockchain indexing
  • Chain reorganization

Frequently asked questions

Is a subgraph the same as The Graph?

No. The Graph is the protocol and network. A subgraph is one indexing definition deployed on it. Providers such as Goldsky and Alchemy also host subgraphs written in the same format.

Why can two subgraphs report different numbers for the same protocol?

Each deployer writes its own mapping logic, contract list and pricing assumptions. Differences in those choices, or one subgraph lagging or halted at a block, produce different totals from the same underlying chain data.

Does a subgraph capture all onchain activity?

No. It records only what its handlers process, typically events from contracts listed in its manifest. State changes that emit no event, and unlisted contracts, are not included.


See the data behind this post. Browse the full dataset catalogue, or read What Is Onchain Data Normalization? for how the records are put together.


Allium provides onchain data infrastructure. Companies named in this article may be Allium customers, prospects or commercial counterparties. The authors and other Allium personnel may hold positions in the assets discussed. This article is informational only and is not investment, legal or tax advice. Data and information last reviewed: November 17, 2026.