Subgraph Manifest

By Alex Numeris

A Subgraph Manifest is a structured configuration file written in YAML format that defines the essential components and behavior of a subgraph within The Graph protocol. It specifies the data sources, smart contracts, events, and mappings that the subgraph will index and process, serving as the blueprint for how blockchain data is transformed into a queryable GraphQL API. The Subgraph Manifest is critical for enabling decentralized applications (dApps) to efficiently access and interact with blockchain data.

What Is Subgraph Manifest?

A Subgraph Manifest is a YAML file (commonly named `subgraph.yaml`) that outlines the configuration and structure of a subgraph in The Graph ecosystem. It acts as a roadmap for indexing specific blockchain data, detailing which smart contracts to monitor, which events to track, and how to process the data into a format that can be queried using GraphQL.

The Subgraph Manifest is essential for defining the scope and functionality of a subgraph. It includes key components such as data sources (blockchain networks and smart contracts), event handlers (to capture specific blockchain events), and mappings (custom logic written in AssemblyScript to transform raw data). Without the Subgraph Manifest, The Graph protocol would lack the instructions needed to index and serve blockchain data effectively.

Who Uses Subgraph Manifest?

The Subgraph Manifest is primarily used by developers building decentralized applications (dApps) and blockchain-based projects that require efficient access to on-chain data. These developers rely on The Graph protocol to index and query blockchain data, and the Subgraph Manifest is the starting point for creating a subgraph.

Additionally, data analysts, blockchain researchers, and other stakeholders in the Web3 ecosystem may indirectly benefit from the Subgraph Manifest, as it enables the creation of subgraphs that provide structured and queryable data for their use cases.

When Is Subgraph Manifest Used?

The Subgraph Manifest is used during the development and deployment of a subgraph. It is created at the beginning of the subgraph development process and serves as the foundation for defining how blockchain data will be indexed and processed.

Once the Subgraph Manifest is written, it is deployed to The Graph’s decentralized network or hosted service. From that point onward, the manifest guides the indexing process, ensuring that the subgraph continuously tracks and processes relevant blockchain data in real time.

Where Is Subgraph Manifest Used?

The Subgraph Manifest is used within The Graph ecosystem, specifically in the context of creating and deploying subgraphs. It resides in the subgraph’s project directory and is typically stored in a version control system like GitHub for collaborative development and version tracking.

The manifest is also utilized by The Graph’s indexing nodes, which read the configuration file to understand what data to index and how to process it. These nodes operate within The Graph’s decentralized network or hosted service, depending on the deployment environment.

Why Is Subgraph Manifest Important?

The Subgraph Manifest is crucial because it provides the instructions needed to transform raw blockchain data into a structured and queryable format. Without it, The Graph protocol would not know which data to index or how to process it, making it impossible to create subgraphs that serve as efficient data layers for dApps.

Key reasons for its importance include:

  • Defining the scope of data indexing, ensuring only relevant data is processed.
  • Enabling developers to customize data transformation logic through mappings.
  • Facilitating efficient and scalable data querying for dApps via GraphQL APIs.
  • Supporting interoperability across different blockchain networks and smart contracts.

In essence, the Subgraph Manifest bridges the gap between raw blockchain data and the user-friendly APIs that power decentralized applications.

How Does Subgraph Manifest Work?

The Subgraph Manifest works by providing a detailed configuration that The Graph’s indexing nodes use to fetch, process, and store blockchain data. Here’s how it functions step by step:

  • The developer writes the Subgraph Manifest in YAML format, specifying data sources (e.g., Ethereum smart contracts) and the events to track.
  • The manifest includes mappings, which are custom scripts written in AssemblyScript. These mappings define how raw blockchain data is transformed into entities that can be queried.
  • The manifest is deployed to The Graph’s network or hosted service, where indexing nodes read the configuration and begin fetching data from the specified blockchain.
  • The indexing nodes process the data according to the mappings and store it in a queryable format.
  • Users and dApps query the indexed data using GraphQL, accessing the structured information defined by the Subgraph Manifest.

By serving as the blueprint for subgraph creation, the Subgraph Manifest ensures that blockchain data is indexed and served in a way that meets the specific needs of developers and their applications.

Share This Article