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:
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.
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.
The codegen step generates code files for indexing and querying data based on your schema and mappings.
Run in your project root:
Copy
Ask AI
graph codegen
Success output:
Copy
Ask AI
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2 Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3 Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4 Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5 Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6 Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2 Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4 ✔ Apply migrations ✔ Load subgraph from subgraph.yaml Load contract ABI from abis/factory.json Load contract ABI from abis/ERC20.json Load contract ABI from abis/ERC20SymbolBytes.json Load contract ABI from abis/ERC20NameBytes.json ✔ Load contract ABIs Generate types for contract ABI: Factory (abis/factory.json) Generate types for contract ABI: ERC20 (abis/ERC20.json) Generate types for contract ABI: ERC20SymbolBytes (abis/ERC20SymbolBytes.json) Generate types for contract ABI: ERC20NameBytes (abis/ERC20NameBytes.json) Write types to generated/Factory/Factory.ts Write types to generated/Factory/ERC20.ts Write types to generated/Factory/ERC20SymbolBytes.ts Write types to generated/Factory/ERC20NameBytes.ts ✔ Generate types for contract ABIs Generate types for data source template Pair Write types for templates to generated/templates.ts ✔ Generate types for data source templates Load data source template ABI from abis/pair.json Load data source template ABI from abis/factory.json ✔ Load data source template ABIs Generate types for data source template ABI: Pair > Pair (abis/pair.json) Generate types for data source template ABI: Pair > Factory (abis/factory.json) Write types to generated/templates/Pair/Pair.ts Write types to generated/templates/Pair/Factory.ts ✔ Generate types for data source template ABIs ✔ Load GraphQL schema from schema.graphql Write types to generated/schema.ts ✔ Generate types for GraphQL schema Types generated successfully