graph托管服务目前支持的主网
- Ethereum mainnet
- Kovan
- Rinkeby
- Ropsten
- Goerli
- PoA-Core
- PoA-Sokol
- xDAI
- Matic
- Mumbai
- Fantom
- Binance Smart Chain
- Clover
- Avalanche
- Fuji
- Celo
- Celo-Alfajores
- Fuse
- Moonbeam
- Arbitrum One
- Arbitrum Testnet (on Rinkeby)
- Optimism
- Optimism Testnet (on Kovan)
托管subugraph
-
安装yarn,node环境
设置yarn仓库curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
设置node仓库curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
开始安装sudo yum install yarn
安装成功yarn --version
配置国内镜像yarn config set registry https://registry.npm.taobao.org
-
安装graph-cli
Install with yarn:yarn global add @graphprotocol/graph-cli
Install with npm:npm install -g @graphprotocol/graph-cli
-
访问thegraph服务,进入graph studio,创建subgraph,生成SUBGRAPH_SLUG
-
初始化subgraph
graph init --studio <SUBGRAPH_SLUG>
-
修改配置,完成编码
-
进行auth认证
graph auth --studio <DEPLOY KEY>
-
发布subgraph
graph deploy --studio <SUBGRAPH_SLUG>
自建graph节点
官方quick start
This guide uses Truffle and Ganache for local development. It covers the following steps:
1. Set up Ganache CLI
2. Start a local Graph Node
3. Initialize a new subgraph
4. Deploy an example smart contract to Ganache
5. Deploy the subgraph to the local Graph Node
6. Use the subgraph in a dApp built with React
根据上述步骤进行实操
-
我们以接入ethereum为测试目标,第一步忽略
-
Graph Node依赖postgres 、ipfs服务,我们以docker部署为例
-
运行postgres 镜像
docker run --name=postgres -p 15432:5432 -e POSTGRES_PASSWORD=postgres -e TZ=PRC -d postgres
-
运行ipfs镜像
docker run -d --name ipfs \
-v /home/work/app/ipfs-node/staging:/export \
-v /home/work/app/ipfs-node/data:/data/ipfs \
-p 5001:5001 \
ipfs/go-ipfs:latest
- 运行graph node节点
docker run -it -d --name graph-node-ropsten \
-p 8000:8000 -p 8001:8001 -p 8020:8020 -p 8030:8030 \
-e GRAPH_ALLOW_NON_DETERMINISTIC_FULLTEXT_SEARCH="true" \
-e postgres_host=172.18.0.1 \
-e postgres_port=5432 \
-e postgres_user=postgres \
-e postgres_pass=postgres \
-e postgres_db=graph-node-ropsten \
-e ipfs=172.18.0.1:5001 \
graphprotocol/graph-node:latest
-
创建一个新的subgraph
我们拉取uniswap-v2的subgraph代码,来进行实验https://github.com/Uniswap/uniswap-v2-subgraph
修改subgraph.yml配置文件
主要修改address地址 -
忽略
-
发布subgraph到我们的自建节点
安装代码依赖$ yarn && yarn codegen
创建本地graph$ yarn create-local
发布到本地节点$ yarn deploy-local
文章来源:https://www.toymoban.com/news/detail-484870.html -
使用graphql进行查询文章来源地址https://www.toymoban.com/news/detail-484870.html
到了这里,关于thegraph使用指南的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!