Run subgraphs without full nodes
This tutorial uses alpha-quality software. If you encouter any issues while using it please let us know at the SquidDevs Telegram chat.
Dependencies: Docker, Git, NodeJS, Yarn.
Developing and running subgraphs is hard, as one has to run a full archival node, and for many networks it is not feasible to run a full archival node to at all.
Subsquid Firehose is an open-source lightweight adapter run as a side-car to a graph indexer node, ingesting and filtering the data directly from Subsquid Network instead of an RPC endpoint. However, since the network does not provide the real-time blocks, the most recent and unfinalized blocks are (optionally) ingested from a complementary RPC endpoint in a seamless way.
Currently it is only possible to run subgraphs against a production-ready permissioned Subsquid Network instance (formerly known as Subsquid Archives). Running against the decentralized Subsquid Network is scheduled to be supported in Q2 2024 (see Subsquid Network Overview to learn more about the difference).
The easiest way to run a subgraph with Subsquid Firehose to use our graph-node-setup repo. Here's how:
Clone the repo and install the dependencies:
git clone https://github.com/subsquid-labs/graph-node-setup
Interactively configure the environment with
npm run configure
Optionally you can also provide an RPC endpoint. If you do, it will be used to sync a few thousands of blocks at the chain end, so it does not have to be a paid one. However,
firehose-grpcdoes not limit its request rate yet, so using a public RPC might result in a cooldown.
If you do not provide an RPC endpoint, your subgraph deployments will be a few thousands of blocks behind the chain head.warning
Running against the decentralized testnet is not currently supported. This feature will be re-enabled in Q2 2024.
Download and deploy your subgraph of choice! For example, if you configured the environment to use Ethereum mainnet (
eth-mainnet), you can deploy the well known Gravatar subgraph:
git clone https://github.com/graphprotocol/example-subgraph
# the repo is a bit outdated, giving it a deps update
npx --yes npm-check-updates --upgrade
# generate classes for the smart contract
# and events used in the subgraph
npm run codegen
# create and deploy the subgraph
npm run create-local
npm run deploy-local
GraphiQL playground will be available at http://127.0.0.1:8000/subgraphs/name/example/graphql.
Do not hesitate to let us know about any issues (whether listed here or not) at the SquidDevs Telegram chat.
- If your subgraph is not syncing and you're getting
errors in the
thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', src/ds_rpc.rs:556:80
graph-node-setup-firehosecontainer logs, that likely means that the chain RPC is not fully Ethereum-compatible and a workaround is not yet implemented in
firehose-grpc. You can still sync your subgraph with RPC ingestion disabled.