Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Subgraph Manifest

A Subgraph Manifest is a YAML or JSON configuration file that defines the smart contracts, events, and data transformations for a subgraph to be indexed by a protocol like The Graph.
Chainscore © 2026
definition
THE BLUEPRINT

What is a Subgraph Manifest?

A Subgraph Manifest is the core configuration file that defines what data a subgraph indexes from a blockchain and how it is transformed and stored.

A Subgraph Manifest is a YAML or JSON file, typically named subgraph.yaml, that serves as the complete blueprint for a subgraph on The Graph protocol. It explicitly defines the smart contracts to index, the specific blockchain events to listen for, and the precise mapping functions that translate raw blockchain data into queryable entities. This manifest is the single source of truth for the subgraph's data pipeline, instructing the Graph Node on how to process historical and real-time data from a specified network.

The manifest's structure is organized into several key sections. The dataSources block specifies the smart contract ABI, address, and start block. The most critical component is the eventHandlers list, which links specific contract events to handler functions written in AssemblyScript. These handlers, defined in a separate mapping file, contain the logic for creating, updating, or deleting entities in the subgraph's database. Additional sections configure the network (e.g., Ethereum mainnet, Arbitrum), the schema of the resulting data, and templates for dynamically adding data sources.

When a developer deploys a subgraph, the Graph Node ingests this manifest to begin the indexing process. It scans the blockchain from the defined start block, executes the mapping logic for each matching event, and populates a PostgreSQL database with the structured entities. Consequently, any change to the subgraph's behavior—such as indexing a new event or modifying an entity field—requires an update to the manifest and a redeployment. This declarative approach separates the data indexing logic from the query layer, enabling powerful and efficient GraphQL APIs for decentralized applications.

how-it-works
THE BLUEPRINT

How a Subgraph Manifest Works

The subgraph manifest is the core configuration file that defines what data a subgraph will index, where it will source it, and how it will transform it into queryable entities.

A subgraph manifest is a YAML or JSON file, typically named subgraph.yaml, that acts as the complete blueprint for a subgraph. It specifies the smart contract to index, the blockchain network it resides on, the events to listen for, and the mapping logic that translates raw blockchain data into the structured GraphQL schema. This file is the single source of truth for The Graph's indexing node, telling it exactly what to index and how to process it. Without a properly configured manifest, a subgraph cannot be deployed or begin indexing data.

The manifest is structured into several key sections. The dataSources section defines the smart contract address, the blockchain network (e.g., mainnet, arbitrum-one), and the contract ABI. The templates section allows for dynamic data source creation. Crucially, the eventHandlers within each data source link specific contract events to handler functions in the mapping script. Finally, the manifest references the schema.graphql file, ensuring the mapping's output conforms to the defined data model. This declarative approach separates the what (the manifest) from the how (the mapping code).

During deployment, The Graph's tooling, like the Graph CLI, validates and processes the manifest. It compiles the mapping code (written in AssemblyScript or other supported languages), ensures the schema is syntactically correct, and registers the subgraph's intent with the network. Once deployed, the indexing node reads the manifest to understand its starting block, begins scanning the chain for the specified events, and executes the corresponding handler functions to populate the database. Any change to the subgraph's logic or data sources requires an update to the manifest and a new deployment.

For developers, working with the manifest involves careful configuration of startBlock to optimize indexing speed, defining efficient eventHandlers to capture only necessary data, and managing dataSource templates for factory contracts that deploy new instances. A well-crafted manifest is essential for subgraph performance and accuracy, as errors here can lead to missed events or incorrect data transformations. It is the foundational document that bridges the on-chain world with the queryable off-chain database.

key-components
SUBGRAPH MANIFEST

Key Components of a Subgraph Manifest

The subgraph manifest (subgraph.yaml) is the central configuration file that defines the data sources, mapping logic, and schema for a subgraph. It instructs The Graph's indexing node on what data to index and how to transform it.

01

Data Sources

Defines the smart contracts and blockchain events the subgraph will index. Each source specifies the contract address, ABI, and the start block from which to begin indexing.

  • Ethereum Contract: The primary data source for most subgraphs, pointing to a deployed smart contract.
  • Start Block: A critical optimization that tells the indexer to skip historical blocks before the contract's deployment.
02

Schema Definition

References the GraphQL schema file (schema.graphql) that defines the shape of the queryable data. This schema declares the entities (like User, Transaction, Pool) and their fields that will be populated by the mapping logic.

  • Entities: Represent indexed data objects stored and queryable from the GraphQL API.
  • @entity Directive: Marks a GraphQL type as an entity to be stored in the database.
03

Mapping Handlers

Specifies the AssemblyScript code that processes blockchain events. Handlers are functions triggered by specific contract events or function calls, translating raw log data into the entities defined in the schema.

  • Event Handlers: e.g., eventHandlers for Transfer(address,address,uint256).
  • Call Handlers: For indexing specific function calls.
  • Block Handlers: Run on every new block or at specific intervals.
04

Network & Protocol

Declares the blockchain network and the specific decentralized protocol the subgraph indexes. This tells the indexer which blockchain to connect to and the rules for that chain.

  • network: e.g., mainnet, arbitrum-one, polygon.
  • protocol: Typically ethereum for EVM chains.
  • source.address: The contract address on the specified network.
05

Templates & Dynamic Data Sources

Allows for the creation of data sources dynamically at runtime. Used for indexing contracts created by a factory pattern, where new instances (like Uniswap V3 pools or NFT collections) are deployed after the subgraph starts.

  • Template Source: Defines a contract template with an ABI.
  • Create Call: A mapping handler uses dataSource.create() to instantiate a new data source from a template.
data-source-definition
THE SUBGRAPH MANIFEST

Defining Data Sources

The foundational configuration file that defines a subgraph's data sources, mappings, and deployment parameters.

A Subgraph Manifest is a YAML or JSON configuration file (typically subgraph.yaml) that serves as the complete blueprint for a subgraph, defining the smart contracts to index, the events to track, and the logic for transforming blockchain data into queryable entities. It is the single source of truth for The Graph's indexing node, instructing it on precisely what data to ingest and how to process it. This declarative file is the first artifact created when developing a subgraph and is essential for its deployment to a decentralized network or a hosted service.

The manifest's core sections define the data sources. Each data source specifies a smart contract address, its Application Binary Interface (ABI), the blockchain network, and the starting block for indexing. Crucially, it lists the specific contract events and function calls that the subgraph will monitor. The mapping section then links this data to the transformation logic, pointing to the handler functions written in AssemblyScript that will process these events and populate the subgraph's GraphQL schema. This separation of configuration and logic allows for clear, maintainable subgraph definitions.

Beyond core indexing rules, the manifest includes important metadata like the subgraph's name and version, and it can define templates for dynamically created data sources. For instance, a factory contract that deploys new trading pairs can be configured to automatically spawn a new data source for each new contract, without manual updates. Advanced features like call handlers for tracking specific function executions and block handlers for processing every new block are also configured here, making the manifest a powerful tool for capturing complex blockchain state.

mapping-logic
SUBGRAPH CORE

Mapping Logic & Event Handlers

The engine of a subgraph, where on-chain data is transformed into queryable entities.

Mapping logic is the executable code that processes blockchain events and function calls, translating raw transaction data into structured entities within a subgraph's data store. This logic is defined in a mapping file, typically written in AssemblyScript, and is triggered by event handlers and call handlers specified in the subgraph manifest. Each handler is a function that receives the decoded blockchain data as an input parameter, allowing developers to write custom business logic for creating, updating, or deleting entities in response to on-chain activity.

An event handler is the most common mapping trigger, invoked when a specific smart contract event, or log, is emitted on-chain. The handler function receives the event's indexed and non-indexed parameters as typed objects. For example, a Transfer(address indexed from, address indexed to, uint256 value) event would trigger a handler that could create a TransferEntity or update User entity balances. The precision of these handlers is what allows subgraphs to maintain a precise, real-time reflection of contract state.

A call handler provides an alternative mapping trigger, executing logic in response to specific smart contract function calls, even if they do not emit an event. This is crucial for indexing state-changing calls to functions marked as external or public. Block handlers run once per new block, enabling the indexing of block-level data like miner rewards or difficulty, while transaction handlers run for every transaction, useful for tracking gas prices or transaction origins. The choice of handler depends on the specific data sourcing requirement.

Within the mapping function, developers interact with the store via the Entity API. The core operations are entity.save() to persist a new or updated entity and entity.load() to retrieve an existing entity for modification. This is where the logic applies the business rules: calculating derived statistics, updating aggregate balances, or establishing relationships between entity types. All changes made within a handler are atomically committed to the store, ensuring data consistency.

Effective mapping design is critical for subgraph performance and correctness. Best practices include minimizing state lookups, avoiding unnecessary computations, and ensuring handler logic is deterministic—it must produce the same entity changes for the same on-chain inputs every time. Since mappings process every relevant event from the start block onward, efficient logic ensures the subgraph can sync quickly and remain cost-effective to host and query.

schema-definition
SUBGRAPH MANIFEST

The GraphQL Schema

The GraphQL Schema is the core definition file within a subgraph manifest that dictates the shape of the data your subgraph will index and serve via its API.

A GraphQL Schema is a declarative contract written in the GraphQL Schema Definition Language (SDL) that defines the data types, fields, and relationships that a subgraph will expose. It serves as the blueprint for the subgraph's API, specifying exactly what queries can be made and what data structures will be returned. Every entity, scalar, enum, and interface used by the subgraph must be explicitly defined in this schema file, which is typically named schema.graphql. This schema is the single source of truth for the subgraph's data model.

The schema's primary components are entity types, which represent indexed objects like User or Transaction. Each entity is defined with fields that have specific GraphQL scalar types (String, Int, BigInt, Bytes, etc.) or references to other entities, establishing relationships. The @entity directive marks a type for indexing, while the @derivedFrom directive creates a reverse lookup on a relationship. This schema directly informs the generation of the underlying database tables and the structure of the GraphQL API endpoint.

Beyond static definitions, the schema supports enums for predefined value sets, interfaces for shared fields across entities, and union types for flexible return values. Crucially, the schema is tightly coupled with the subgraph's mapping logic written in AssemblyScript; the mappings are responsible for populating the entities defined here with data sourced from blockchain events. Any change to the schema necessitates a redeployment of the subgraph, as it alters the fundamental data structure.

ecosystem-usage
SUBGRAPH MANIFEST

Ecosystem Usage & Examples

The subgraph manifest (subgraph.yaml) is the central configuration file that defines a subgraph's data sources, mapping logic, and schema. It is the blueprint The Graph's indexing node uses to process blockchain data.

01

Core Structure & Components

The manifest is a YAML file with three primary sections:

  • dataSources: Defines the smart contracts to index, their network (e.g., mainnet), and the ABI file.
  • templates: Allows for dynamic data source creation for contracts deployed after subgraph creation.
  • schema.graphql: References the GraphQL schema file that defines the shape of the queryable data entities.
  • mapping.handlers: Links contract events and functions to the handler functions in the AssemblyScript mapping file.
02

Defining Data Sources

Each dataSource block specifies the exact smart contract to monitor. Key fields include:

  • kind: Almost always ethereum/contract.
  • name: A human-readable identifier for the contract.
  • network: The blockchain network (e.g., mainnet, arbitrum-one, sepolia).
  • source: Contains the contract's address and the abi file name.
  • mapping: Points to the eventHandlers (e.g., - event: Transfer(indexed address,indexed address,uint256)) and the corresponding handler function in the mapping script.
03

Handling Multiple Contracts

Manifests can index multiple related contracts, which is common for DeFi protocols. For example, a Uniswap V2 subgraph would define separate data sources for:

  • The Factory contract (to track new pairs).
  • Each Pair/Pool contract (to track swaps, liquidity). Using contract templates, a subgraph can automatically begin indexing new Pair contracts the moment the Factory deploys them, without manual updates.
05

Deployment & Versioning

After writing the manifest and associated files, developers use the Graph CLI to deploy it.

  • The command graph deploy compiles the mappings, validates the manifest against the schema, and publishes the subgraph to either the hosted service or the decentralized network.
  • Each deployment creates a new version of the subgraph. The manifest is immutable once deployed, requiring a new version for any updates to data sources, mappings, or the schema.
06

Common Tools & Validation

Developers rely on specific tools to work with the manifest:

  • Graph CLI: For code generation (graph codegen creates TypeScript bindings from the ABI and schema) and deployment.
  • Schema Validation: The CLI ensures all entities referenced in the mapping exist in the schema.graphql.
  • ABI Management: The abis/ folder stores contract ABIs, which must be kept in sync with the live contracts for accurate event decoding.
SUBGRAPH COMPONENTS

Manifest vs. Schema: A Comparison

Core differences between the configuration and data definition files in a subgraph.

FeatureManifest (subgraph.yaml)Schema (schema.graphql)

Primary Purpose

Configuration and mapping logic

Data model and entity definitions

File Format

YAML

GraphQL SDL

Defines

Data sources, event handlers, and data transformation logic

Entity types, fields, and relationships for the GraphQL API

Used By

The Graph Node during indexing

The Graph Node to generate the API and by client queries

Key Sections

dataSources, templates, network, source, mapping

type, enum, @entity, @derivedFrom

Change Impact

Requires redeployment of the subgraph

Can sometimes require a migration if entities change

Validation

Validated against a JSON schema

Validated by the GraphQL parser

developer-workflow
SUBGRAPH MANIFEST

Developer Workflow with a Manifest

A Subgraph Manifest (subgraph.yaml) is the central configuration file that defines what data to index, how to transform it, and where to store it. This section details the key components and steps involved in building with it.

01

The Manifest Blueprint

The subgraph.yaml file is the source of truth for your subgraph. It specifies three core sections:

  • dataSources: Defines the smart contracts to index, their ABIs, and the network (e.g., mainnet, Goerli).
  • templates: Allows for dynamic data source creation for factory contracts.
  • schema.graphql: References the GraphQL schema that defines the shape of your queryable data entities.
02

Mapping Smart Contract Events

Event handlers in the manifest link on-chain events to executable code. For each data source, you define:

  • eventHandlers: List the specific contract events (e.g., Transfer(address,address,uint256)) to index.
  • handler: Points to the AssemblyScript function in your mapping.ts file that will process the event data, transforming it into entities defined in your schema.
03

Defining the Data Schema

The referenced schema.graphql file uses GraphQL schema definition language to model the indexed data. You define:

  • @entity types: The core data objects (e.g., Token, User).
  • Fields and types: Each entity's attributes (e.g., id: ID!, balance: BigInt).
  • Relationships: Define connections between entities using field types (e.g., token: Token). The manifest ensures mappings populate this structure.
04

The Build & Deploy Cycle

The manifest drives the CLI workflow:

  1. graph codegen: Generates AssemblyScript types from your ABI and schema, creating type-safe mappings.
  2. graph build: Compiles the subgraph (manifest, schema, mappings) into a deployable bundle.
  3. graph deploy: Publishes the bundle to a Graph Node (hosted service or decentralized network), which begins indexing based on the manifest's rules.
05

Handling Contract Upgrades & Forks

The manifest manages protocol evolution. For a new contract version:

  • Create a new data source in the manifest with the new address and ABI.
  • Use context to share data between data sources.
  • For forks, the manifest's startBlock and network specifications ensure the indexer correctly follows the canonical chain.
SUBGRAPH MANIFEST

Frequently Asked Questions (FAQ)

Essential questions and answers about the Subgraph Manifest, the configuration file that defines how a subgraph ingests and transforms blockchain data for The Graph protocol.

A Subgraph Manifest is a YAML or JSON configuration file (typically named subgraph.yaml) that defines the data sources, mapping logic, and schema for a subgraph on The Graph protocol. It acts as the blueprint that tells a Graph Node which smart contracts to index, which events and functions to monitor, and how to transform that on-chain data into queryable entities. The manifest specifies the data sources, the ABI files for the contracts, the event handlers, and the mapping functions written in AssemblyScript that process the raw blockchain data.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team