📡Subgraph CLI Cheat sheet

Streamlined Guide: Deploying Mantle Subgraphs with The Graph CLI

Summary: This cheat sheet condenses essential commands, tips, and best practices into an indispensable reference for anyone deploying a subgraph. Developers will find this streamlined guide invaluable for swiftly progressing through the deployment workflow and resolving frequent pain points. With key information consolidated in one place, engineers can deploy subgraphs more efficiently and focus their efforts on building applications powered by real-time, customizable blockchain data indexes.

Deployment Network definitions

For developers who are already familiar with Graph Protocol tooling, below are the network definitions to deploy subgraphs on Mantle. These settings can be configured in the subgraph.yaml file: For Mantle Andromeda Mainnet:

network: 'mantle'

For Mantle Goerli Testnet:

network: 'mantle-testnet'

For Mantle Sepolia Testnet:

network: 'mantle-sepolia'

1. Get started by install the Graph cli

Download the Graph Cli to cli

npm i @graphprotocol/graph-cli

2. Authentication with API key

  1. Authenticate using the Graph Cli and API key.

Note: You need to specify the Mantle deployment endpoint. Your API key should only be used for the Mantle deployment endpoint.

graph auth https://subgraph-api.mantle.xyz/deploy

Copy your API key when promoted by the command line

What is the deploy key?: ABCDE1234
Deploy key set for http://subgraph-api.mantle.xyz/deploy

3. Generate types and mappings for your subgraph

  1. Go to your subgraph root directory where subgraph.yaml file is located.

cd <your_subgraph_project>
  1. Run the following command to generate types and mapping for your subgraph project

graph codegen

4. Compile your subgraph

  1. Run the following command to compile your subgraph into WASM (WebAssembly).

graph build        

5. Create your subgraph on Mantle Subgraph

  1. Run the following command to create a subgraph entry on the Mantle Subgraph Service. Note that this step only registers a subgraph and does not deploy the actual subgraph in the Mantle Subgraph service. Note: you need to use --node flag to specify the Mantle deployment endpoint.

graph create <your_subgraph> --node https://subgraph-api.mantle.xyz/deploy

6. Deploy your subgraph to Mantle Subgraph

  1. Run the following command to deploy your subgraph to the Mantle Subgraph Service. Note: you need to use --node flag to specify the Mantle deployment endpoint in order to remove your subgraph from the Mantle Subgraph Service.

graph deploy <your_subgraph> --node https://subgraph-api.mantle.xyz/deploy --ipfs https://subgraph-api.mantle.xyz/ipfs

7. Remove your subgraph from Mantle Subgraph

  1. Run the following command to remove/unregister your subgraph from the Mantle Subgraph Service.

graph remove <your_subgraph> --node https://subgraph-api.mantle.xyz/deploy

Quick Start in the App

The Mantle Subgraph Web App also offers a concise guide to assist users in deploying their subgraphs effectively.

Last updated