Skip to content

Latest commit

 

History

History
80 lines (52 loc) · 2.61 KB

subgraph.md

File metadata and controls

80 lines (52 loc) · 2.61 KB

Running the subgraph in a local env

Deps

Clone the thegraph repo

Official instructions: https://thegraph.com/docs/developer/quick-start

git clone https://github.com/graphprotocol/graph-node/

Adjust to use it with Hardhat

Note: before running the graph node, ensure your local Hardhat node is running. Inside the clr.fund repo:

yarn start:node

Inside the graph node repo:

cd graph-node/docker

Modify the docker-compose.yml file and set the correct Hardhat port been used

ethereum: "hardhat:http://host.docker.internal:18545"

# in Linux machines instead of `host.docker.internal` you should have the host IP address
ethereum: "hardhat:http://<IP>:18545"

Run the node:

docker-compose up

In case you want to stop the node and start it without any subgraph that could have been added before, wipe the db and deploy the subgraph again:

rm -rf data/postgres

Run it locally

# having the thegraph node running in docker, just run this:
# it will deploy the contracts, the subgraph and run the webapp
yarn start:dev

# in case you want to only deploy the subgraph manually, run
# this will build the subgraph using the hardhat configs and then will deploy it into the local graph node
yarn start:subgraph

Common errors

  • Error trace_filter RPC call failed: any callHandlers or blockHandlers definition in the subgraph.yaml file won't work with Hardhat since it doesn't have trace support.

  • M1 Macbook Error: When using docker with the M1 Apple products you will need to use a different image in the docker-compose. Fix found here: graphprotocol/graph-node#2325. To implement fix, go to docker-compose.yml in cd graph-node/docker and change the image to: image: graphprotocol/graph-node:2c23cce for the graph-node service

  • Subgraph Queries returning null: Check that your .env is setup properly with the right VUE_APP_SUBGRAPH_URL. If locally developing use: VUE_APP_SUBGRAPH_URL=http://localhost:8000/subgraphs/name/daodesigner/clrfund

Deployment

Currently, we are using the Hosted Service. First, check out the official instructions to authenicate using the Graph CLI https://thegraph.com/docs/legacyexplorer/deploy-subgraph-hosted

  1. Prepare the subgraph.yaml with the correct network data
    • Update the JSON file that you want to use, located in /subgraph/config
    • Inside the /subgraph folder, run yarn prepare:{network}
  2. Run yarn deploy:subgraph