Deploy Subgraph and start Indexing
The @graphprotocol/graph-cli are required to prepare subgraphs and interact with the graph node.
Install them with npm:
npm install --save @graphprotocol/graph-cliDeploying the subgraph is a multi-step process:
codegengenerates AssemblyScript types from the subgraph's GraphQL schema and the contract ABIs included in the data sources. It must be run when either the schema or ABIs change.buildgenerates the AssemblyScript from the subgraph's indexing scripts.graph creategenerates the namespace on the node where all the subgraph data will be stored. It must only be run once.graph deployuploads the subgraph package to IPFS and instructs the graph node to use it.
codegen******** ****with example output
codegen******** ****with example outputnpx graph codegen vebetterdao/tokens.subgraph.yaml Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
Apply migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
Apply migration: Bump manifest specVersion from 0.0.2 to 0.0.4
✔ Apply migrations
✔ Load subgraph from vebetterdao/tokens.subgraph.yaml
Load contract ABI from node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
Load contract ABI from node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
✔ Load contract ABIs
Generate types for contract ABI: IERC20 (node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json)
Generate types for contract ABI: IERC20 (node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json)
Write types to generated/erc20/IERC20.ts
Write types to generated/erc20-1/IERC20.ts
✔ Generate types for contract ABIs
✔ Generate types for data source templates
✔ Load data source template ABIs
✔ Generate types for data source template ABIs
✔ Load GraphQL schema from vebetterdao/tokens.schema.graphql
Write types to generated/schema.ts
✔ Generate types for GraphQL schema
Types generated successfullybuild with example output
build with example outputgraph create with example output
graph create with example outputThe create command needs to know the service URL of your Graph Node, which is http://127.0.0.1:8020 in the default setup:
graph deploy with example output
graph deploy with example outputThe deploy command needs to know the service URL, the IPFS node to upload the subgraph package and the subgraph definition to upload. In the default setup, the service URL is http://127.0.0.1:8020 and the IPFS node is available on http://127.0.0.1:5001.
The previously generated vebetterdao/tokens.subgraph.yaml is the subgraph definition to upload. A version is required and is used to identify different deployments. In the local environment, versions can be ignored and re-used.
Last updated
Was this helpful?