Quick start guide for deploying a Subgraph using the Command Line Interface (CLI).
The Graph CLI is an essential tool enabling developers to seamlessly create, deploy, and manage subgraphs—providing streamlined blockchain data querying and indexing. It gives you superuser access to our enterprise-grade subgraph infrastructure. Additionally, we are fully compatible with The Graph’s tooling, and the CLI works seamlessly out of the box with our platform.
For developers who are already familiar with Graph Protocol tooling, below are the network definitions to deploy subgraphs on 0xgraph. These settings can be configured in the subgraph.yaml file:
Install CLI Package
Install the graph npm package
Create an API key: Visit 0xgraph Dashboard to generate your API key. For a comprehensive tutorial on generating API keys, visit the Account Creation Page.
You need to specify the 0xgraph deployment endpoint. Your API key should only be used for the 0xgraph deployment endpoint.
Details regarding creating your own Subgraph is beyond the scope of this documentation. The Graph’s official documentation provides detailed guides and examples for each step of the Subgraph creation process. It also covers advanced topics such as indexing strategies, filtering, and pagination. We recommend referring to their documentation for a comprehensive reference on Subgraph development with The Graph.
A typical Subgraph project has the following components:
The subgraph.yaml
manifest file serves as the root configuration, containing smart contract references, entity mappings, handler functions, and deployment parameters like startBlock
and description
.
The schema.graphql
file defines all the entities and their relationships for
your Subgraph’s GraphQL API, determining what blockchain data will be indexed
and made queryable.
Written in AssemblyScript, a TypeScript-like language specifically designed for WebAssembly, the mappings file transforms raw blockchain data into structured entities that match your GraphQL schema through a set of data handling functions.
Messari maintains a well-curated GitHub repository that offers a comprehensive collection of example Subgraphs, which serves as a valuable resource for those seeking to start their subgraph development journey.
Generate Types and Mappings
The codegen step generates code files for indexing and querying data based on your schema and mappings.
Run in your project root:
Success output:
Codegen Options
View all options with graph codegen --help
:
Build Your Subgraph
After generating types, build your subgraph:
Success Output:
Build Options
View all options with graph build --help
:
Deploy your Subgraph
Then deploy your Subgraph:
Success output:
Access your deployed Subgraphs through the web-based UI at form.0xgraph.xyz
Quick start guide for deploying a Subgraph using the Command Line Interface (CLI).
The Graph CLI is an essential tool enabling developers to seamlessly create, deploy, and manage subgraphs—providing streamlined blockchain data querying and indexing. It gives you superuser access to our enterprise-grade subgraph infrastructure. Additionally, we are fully compatible with The Graph’s tooling, and the CLI works seamlessly out of the box with our platform.
For developers who are already familiar with Graph Protocol tooling, below are the network definitions to deploy subgraphs on 0xgraph. These settings can be configured in the subgraph.yaml file:
Install CLI Package
Install the graph npm package
Create an API key: Visit 0xgraph Dashboard to generate your API key. For a comprehensive tutorial on generating API keys, visit the Account Creation Page.
You need to specify the 0xgraph deployment endpoint. Your API key should only be used for the 0xgraph deployment endpoint.
Details regarding creating your own Subgraph is beyond the scope of this documentation. The Graph’s official documentation provides detailed guides and examples for each step of the Subgraph creation process. It also covers advanced topics such as indexing strategies, filtering, and pagination. We recommend referring to their documentation for a comprehensive reference on Subgraph development with The Graph.
A typical Subgraph project has the following components:
The subgraph.yaml
manifest file serves as the root configuration, containing smart contract references, entity mappings, handler functions, and deployment parameters like startBlock
and description
.
The schema.graphql
file defines all the entities and their relationships for
your Subgraph’s GraphQL API, determining what blockchain data will be indexed
and made queryable.
Written in AssemblyScript, a TypeScript-like language specifically designed for WebAssembly, the mappings file transforms raw blockchain data into structured entities that match your GraphQL schema through a set of data handling functions.
Messari maintains a well-curated GitHub repository that offers a comprehensive collection of example Subgraphs, which serves as a valuable resource for those seeking to start their subgraph development journey.
Generate Types and Mappings
The codegen step generates code files for indexing and querying data based on your schema and mappings.
Run in your project root:
Success output:
Codegen Options
View all options with graph codegen --help
:
Build Your Subgraph
After generating types, build your subgraph:
Success Output:
Build Options
View all options with graph build --help
:
Deploy your Subgraph
Then deploy your Subgraph:
Success output:
Access your deployed Subgraphs through the web-based UI at form.0xgraph.xyz