2.0 KiB
2.0 KiB
Deploying Subgraph
Setup
We will use the ethereum-gravatar example subgraph from graphprotocol/graph-tooling repo
-
Clone the repo
git clone git@github.com:graphprotocol/graph-tooling.git cd graph-tooling -
Install dependencies
pnpm install -
Change directory to example-subgraph
cd examples/ethereum-gravatar
Deploy
The following steps should be similar for every subgraph
-
Change the network and address in
subgraph.yaml... dataSources: - kind: ethereum/contract name: Gravity network: <NETWORK_NAME> source: address: '<CONTRACT_ADDRESS>' abi: Gravity startBlock: <START_BLOCK> ...CONTRACT_ADDRESSis the address of the deployed contract on the desired networkSTART_BLOCKis the block number after which we want to process eventsNETWORK_NAMEis the name of the network specified when deploying graph-node- When deploying graph-node
ETH_NETWORKSenv is set to a space-separated list of the networks where each entry has the formNAME:URL - The
NAMEcan be used in subgraph to specify which network to use - More details can be seen in Start the stack section
- When deploying graph-node
-
Build the subgraph
pnpm codegen pnpm build -
Create and deploy the subgraph
pnpm graph create example --node <GRAPH_NODE_DEPLOY_ENDPOINT> pnpm graph deploy example --ipfs <GRAPH_NODE_IPFS_ENDPOINT> --node <GRAPH_NODE_DEPLOY_ENDPOINT>GRAPH_NODE_DEPLOY_ENDPOINTandGRAPH_NODE_IPFS_ENDPOINTwill be available after graph-node has been deployed- More details can be seen in Create a deployment section
-
The subgraph GQL endpoint will be seen after deploy command runs successfully
-
To remove the subgraph
pnpm graph remove --node <GRAPH_NODE_DEPLOY_ENDPOINT> example