A developer's guide to developing and deploying to Alchemy Subgraphs.
What is a Subgraph?
Subgraphs are an open-source tool for building custom GraphQL APIs with blockchain data.
How it works
- Write your subgraph code.
- Deploy to Alchemy Subgraphs.
- Query live blockchain data through your GraphQL API.
Why use a subgraph?
- Ship in days, not weeks - Spend up to 50% less time on data indexing and dealing with forks / reorgs.
- Simplify your infrastructure - Save hours every week on infra maintenance or downtime.
Getting Started
Creating a new subgraph
-
Install the
graph-cli
:npm install -g @graphprotocol/graph-cli
-
Create a new subgraph:
graph init --product hosted-service
-
Make modifications as necessary to the manifest, schema, and handlers.
-
See Developing a Subgraph for more details.
Deploying your subgraph
-
Get your deploy key from your Alchemy Dashboard.
-
Run the following:
cd <SUBGRAPH_DIRECTORY> graph deploy <SUBGRAPH_NAME> \ --version-label <VERSION_NAME> \ --node https://subgraphs.alchemy.com/api/subgraphs/deploy \ --deploy-key <DEPLOY_KEY> --ipfs https://ipfs.satsuma.xyz
See Deploying a Subgraph for more details.
-
You’ll receive a link to view your newly deployed subgraph. Congrats! 🎉