Building & Deploying Subgraph (public graph node)
This tutorial will demonstrate how to build a subgraph and deploy it on harmony public graph node

Install the graph-cli

Our first subgraph

lets use blocklytics/ethereum-blocks subgraph as example
1
git clone https://github.com/blocklytics/ethereum-blocks
2
cd ethereum-blocks
Copied!
we will use Harmony sandbox Graph node (you can run your local one or set up a server for significant projects, see next section)

Edit package.json file and add these lines

1
"create-harmony": "graph create --node https://graph.t.hmny.io:8020 harmony/blocks",
2
"deploy-harmony": "graph deploy --node https://graph.t.hmny.io:8020 --ipfs http://graph.t.hmny.io:5001 harmony/blocks",
Copied!

Update the manifest

Update the manifest subgraph.yaml file datasources[0]['network'] from rinkeby to mainnet If there is no need to index the entire blockchain, you can add an attribute startBlock to speed up the sync : datasources[0]['source']['startBlock']
It is highly recommended to minimize the number of blocks to be indexed to avoid putting load on the RPCs and to speed up the usage of your subgraph/application

Create and deploy the subgraph

1
yarn codegen
2
yarn build
3
yarn create-harmony
4
yarn deploy-harmony
Copied!
Sync begins and you are good to query your subgraph https://graph.t.hmny.io/subgraphs/name/harmony/blocks/graphql​
If multiple developer are deploying a graph and deploy with the same name (ie harmony/blocks) you will have queries and conflict issues, it's recommended to build your own indexer node for your your own testing, see next section
Last modified 1mo ago