当前位置:网站首页>Graph-node部署及测试
Graph-node部署及测试
2022-07-27 05:04:00 【我不想头秃阿】
Graph-node部署及测试
一、环境准备
二、运行本地图节点
- 在终端中,克隆https://github.com/graphprotocol/example-subgraph,并安装依赖项并为合约 ABI 生成类型:(yarn安装)
yarn
yarn codegen
- 在终端中,克隆https://github.com/graphprotocol/graph-node,然后运行
cargo build
- 运行ganache
./ganache-2.5.4-linux-x86_64.AppImage &

- 运行ipfs
ipfs daemon

- 在subgraph文件夹下编译并部署智能合约
// 编译
truffle compile
// 部署
truffle migrate

- 在postgreSQL中创建graphnode数据库
sudo su postgres
psql
create database graphnode;

- 在graph-node文件夹下输入以下命令,运行graph-node:
cargo run -p graph-node --release -- \
--postgres-url postgresql://postgres:[email protected]:5432/graphnode \
--ethereum-rpc mainnet:http://127.0.0.1:7545 \
--ipfs 127.0.0.1:5001 --debug

- 修改subgraph文件夹中的subgraph.yaml,将合约地址修改为之前部署的地址
sudo gedit subgraph.yaml


- 使用这个 Gravatar 示例,要让子图在本地运行,在subgraph文件夹下运行:
yarn create-local

- 部署子图
yarn deploy-local

- 此时graph-node上可以看到子图已被部署

- 尝试调用智能合约创建一个gravatar
// 进入控制台
truffle console
// 创建合约实例
GravatarRegistry.deployed().then(instance=>contract=instance)
// 创建一个displayName为Tom的Gravatar
contract.createGravatar('Tom','Url')
// 指定调用合约的账户
contract.createGravatar('Lucy','Url2',{from: '0x761AE16Df0bF66E6d461F1C936F40e61F2fE1Ed7'})
- 交易成功界面

- graph-node获取到调用合约记录并log

- 访问http://127.0.0.1:8000/subgraphs/name/example/graphql可以进行graphql

END
边栏推荐
- Native token generation encryption and decryption
- Introduction to C language pointer
- Logic of image uploading
- 程序环境和预处理(下):#define、#undef、命令行编译、条件编译、文件包含(超全整理,建议收藏!!!
- Time complexity and space complexity
- Program environment and preprocessing (Part 2): define, undef, command line compilation, conditional compilation, file inclusion (super full collation, recommended collection!!!
- 攻防世界-lottery
- c语言字符串函数下:strcmp、strncpy、strncat、strncmp、strstr、strtok、strerror
- JS中for...of和for...in的区别
- 信息学奥赛一本通1178题——成绩排序
猜你喜欢
随机推荐
函数和箭头函数
维持登录,路由跳转
First acquaintance with C language - first acquaintance with pointer
「PHP基础知识」PHP语句和语句块
while循环
Share a multiple-choice question about the process of program compilation (including a brief discussion on the compilation process, the formation and merging process of symbol tables)
Program environment and preprocessing (Part 1): how does a program run successfully?
C language string function: StrCmp, strncpy, strncat, strncmp, strstr, strtok, strError
[NPUCTF2020]ReadlezPHP 1
JS中是如何使用for..of来遍历对象
Introduction to C language pointer
qsort — c语言中自带的排序函数(附带void*、回调函数知识点
Makefile is easy to understand and explain
JS中原型及原型链
GCC 编译选项
map结构
First knowledge of C language -- constants and variables
Sharing force buckle-189. Three solutions of rotation array
[网鼎杯 2020 青龙组]AreUSerialz(BUUCTF)
C language elementary level -- branch statement (if, switch)







![[网鼎杯 2020 朱雀组]Nmap 1两种解法](/img/fa/b1349cb42b5768b7510217239ba73a.png)

