This repository contains The Graph protocol subgraphs configured for Beam network.
Included subgraphs:
blocks
- forked from blocklytics/ethereum-blocksuniswap-v2
- forked from uniswap/v2-subgraphens
- forked from ensdomains/ens-subgraphvalidator-manager
- subgraph for Beam proof of stake
- install Node.js >=20 and yarn >=1.22
- run
yarn
from the repository root to install dependencies
The default network names used in this repo are beam
and beam-testnet
. Your target graph-node's config must match one of these values. You can find instructions on how to set up your graph-node with Beam below.
You don't need to install graph-cli, since every subgraph package comes with it's own particular setup to use, depending on the version its code was written for. If you'd need it nevertheless, install it using yarn global add @graphprotocol/graph-cli
.
All subgraph packages in this monorepo share the following commands to facilitate the development workflow (the extension :test
refers to using Beam testnet):
codegen[:test]
: generate types from ABIs and GraphQL schemabuild[:test]
: build TS into WASM and compile subgraphindex[:test]
: create a subgraph on the graph-node (not usingcreate
here to avoid clash withyarn create
)deploy[:test]
: deploy the subgraph to the graph-nodeall[:test]
: all of the above in sequence
To execute any command for a specific subgraph, use yarn <subfolder> <command>
, e.g.:
# testnet, step by step
yarn blocks codegen:test
yarn blocks build:test
yarn blocks index:test
yarn blocks deploy:test
# mainnet, using shortcut
yarn uniswap-v2 all
To customize any of these subgraphs for other networks, check the following for your package:
- add your network and contract setup in
networks.json
- packages using older versions of graph-cli may have separate
network.[networkName].json
files
- packages using older versions of graph-cli may have separate
- update node urls and network names in the commands in
package.json > scripts
(we recommend to introduce your own commands, e.g.build:myNetwork
) - for
uniswap-v2
only: see./src/configs/*
for all necessary parameters
- set up a VPS, install
git
,docker
,docker-compose
- e.g. via
sudo apt install git docker docker-compose -y
- e.g. via
- clone graph-node
git clone --depth=1 https://github.com/graphprotocol/graph-node.git
- update
docker-compose.yml
in./graph-node/docker
(see also docs)- change
graph-node > environments > ethereum
to look like this:<network name>:<rpc url>
, e.g.beam:https://myArchiveRpc.foo
- update
postgress_pass
andPOSTGRES_PASSWORD
to not use the default password
- change
- create a systemd service to run the docker containers automatically
- create
/etc/systemd/system/graph.service
, e.g. by runningsudo nano /etc/systemd/system/graph.service
and pasting the contents below from the clipboard - update
User
andWorkingDirectory
to match your setup
- create
[Unit]
Description=graph
Requires=docker.service
After=docker.service
[Service]
Restart=always
User=root
Group=docker
WorkingDirectory=/root/graph-node/docker
ExecStartPre=/usr/bin/docker-compose -f docker-compose.yml down
ExecStart=/usr/bin/docker-compose -f docker-compose.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose.yml down
[Install]
WantedBy=multi-user.target
- enable and run services
sudo systemctl start docker
sudo systemctl enable graph
sudo systemctl start graph
sudo systemctl status graph
- an archive node is required to run the graph-node
- do not run service as root/superuser
- exposed admin endpoints should be protected
- SSL needs to be set up (e.g. via nginx reverse proxy + certbot)