From 51c65d30bda11c770a4893a5255ac9158bc7756a Mon Sep 17 00:00:00 2001 From: Nabarun Date: Wed, 27 Sep 2023 12:11:05 +0530 Subject: [PATCH] Add readme to deploy subgraphs --- app/data/stacks/graph-node/README.md | 14 ++-- app/data/stacks/graph-node/deploy-subgraph.md | 68 +++++++++++++++++++ 2 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 app/data/stacks/graph-node/deploy-subgraph.md diff --git a/app/data/stacks/graph-node/README.md b/app/data/stacks/graph-node/README.md index 3bcbf8a1..0527efc0 100644 --- a/app/data/stacks/graph-node/README.md +++ b/app/data/stacks/graph-node/README.md @@ -38,17 +38,21 @@ Initialize deployment and create "spec" file: laconic-so --stack graph-node deploy init --output graph-node-spec.yml ``` -We need to assign a fixed port `8000` for subgraph GQL endpoint and `8020` for subgraph deployment. The values can be +We need to assign fixed ports: `8000` for subgraph GQL endpoint, `8020` for subgraph deployment and `5001` for IPFS. The values can be customized by editing the "spec" file generated by `laconic-so deploy init`. ``` $ cat graph-node-spec.yml stack: graph-node ports: graph-node: - - '8000:8000' - - '8001' - - '8020:8020' - - '8030' + - '8000:8000' + - '8001' + - '8020:8020' + - '8030' + ipfs: + - '8080' + - '4001' + - '5001:5001' ... ``` diff --git a/app/data/stacks/graph-node/deploy-subgraph.md b/app/data/stacks/graph-node/deploy-subgraph.md new file mode 100644 index 00000000..73e200b2 --- /dev/null +++ b/app/data/stacks/graph-node/deploy-subgraph.md @@ -0,0 +1,68 @@ +# Deploying Subgraph + +## Setup + +We will use the [ethereum-gravatar](https://github.com/graphprotocol/graph-tooling/tree/%40graphprotocol/graph-cli%400.58.0/examples/ethereum-gravatar) example subgraph from `graphprotocol/graph-tooling` repo + +- Clone the repo + ```bash + git clone git@github.com:graphprotocol/graph-tooling.git + + cd graph-tooling + ``` + +- Install dependencies + ```bash + pnpm install + ``` + +- Change directory to example-subgraph + ```bash + cd examples/ethereum-gravatar + ``` + +## Deploy + +The following steps should be similar for every subgraph + +- Change the network and address in `subgraph.yaml` + ```yaml + ... + dataSources: + - kind: ethereum/contract + name: Gravity + network: + source: + address: '' + abi: Gravity + startBlock: + ... + ``` + - `CONTRACT_ADDRESS` is the address of the deployed contract on the desired network + - `START_BLOCK` is the block number after which we want to process events + - `NETWORK_NAME` is the name of the network specified when deploying graph-node + - When deploying graph-node `ETH_NETWORKS` env is set to a space-separated list of the networks where each entry has the form `NAME:URL` + - The `NAME` can be used in subgraph to specify which network to use + - More details can be seen in [Start the stack](./README.md#start-the-stack) section + +- Build the subgraph + ```bash + pnpm codegen + pnpm build + ``` + +- Create and deploy the subgraph + ```bash + pnpm graph create example --node + + pnpm graph deploy example --ipfs --node + ``` + - `GRAPH_NODE_DEPLOY_ENDPOINT` and `GRAPH_NODE_IPFS_ENDPOINT` will be available after graph-node has been deployed + - More details can be seen in [Create a deployment](./README.md#create-a-deployment) section + +- The subgraph GQL endpoint will be seen after deploy command runs successfully + +- To remove the subgraph + ```bash + pnpm graph remove --node example + ``` -- 2.45.2