Subgraphs that track Cellar statistics
packages
- A yarn workspace that houses shared libraries such as abis and constantssubgraphs
- A yarn workspace that houses subgraph packages
cd cellar-subgraphs
yarn
npm install -g yarn
Install nodejs. I like to use node version manager (nvm)
Subgraph development has a steep learning curve. One of the best ways to get started is to write your own subgraph that tracks ownership of your favorite ERC721 token. One thing to always keep in mind is the Graph's AssemblyScript compiler implements a subset of Assemblyscript. Below are some linked docs that detail some of the idiosyncracies and are worth going over:
You'll need to have a graph-node
running locally to deploy a subgraph for development. The Graph Protocol team has a premade docker setup that spins up all the dependencies: Postgres, an IPFS node, and a graph-node.
First and foremost, obtain a rpc url for the ethereum network you are targeting (mainnet, rinkeby, etc...). Cloud RPC providers such as Alchemy and Infura work pretty well and Alchemy's free tier is quite generous.
git clone [email protected]:graphprotocol/graph-node.git
cd graph-node/docker
Update the docker-compose.yml
file and replace the ethereum rpc url with the one you obtained earlier.
graph-node:
environment:
ethereum: 'mainnet:http://host.docker.internal:8545'
docker compse up
WIP
yarn test
M1 macs are not officially supported but they do have some instructions on how to rebuild the graph-node image and use docker compose up
. Alternatively, you can open a rosetta terminal and run the development version.
- Install Rust in a Rosetta terminal (This will clash with an existing arm64 install! It is possible to run these side by side with the right shell configuration.)
- Start the graph-node
cargo run -p graph-node --release -- \
--postgres-url postgresql://postgres:let-me-in@localhost:5432/graph-node \
--ethereum-rpc mainnet:<your http rpc url> \
--ipfs 127.0.0.1:5001
Your graph node is now up and the graphql interface is reachable at:
http://localhost:8000/subgraphs/name/<subgraph prefix>/<subgraph name>/graphql
yarn workspace <subgraph name> deploy-local
yarn workspace <subgraph name> deploy-hosted