前提条件
请确保您的系统上已安装以下前提条件:- Node.js 和 npm
- Docker
- 一个 Tenderly 账户
- 一个 Virtual Environment RPC
- 一个使用 Hardhat 或 Foundry 部署到 Virtual Environment 的智能合约
设置 The Graph
有关更多详细信息,请参阅官方 Graph CLI 文档。
--abi 使其指向本地系统上的合约 ABI--contract-name 和 --from-contract--start-block--network,使其引用您的 Virtual Environment 所基于的网络(例如 mainnet、base 等)。graph init your-subgraph-name subgraph-dir \
--protocol ethereum \
--studio \
--abi path/to/abi/ERC20Token.json \
--contract-name ERC20TokenFactory \
--from-contract 0x7F2Fa32C991fD2F8dF3EB23C394f550376e9b30d \
--start-block 0 \
--network mainnet
version: '3'
services:
graph-node:
image: graphprotocol/graph-node
ports:
- '8020:8020'
- '8000:8000'
- '5001:5001'
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'mainnet:https://virtual.mainnet.rpc.tenderly.co/d0a6...-40..2c-81..0f-a5..90'
graph codegen
graph create --node http://localhost:8020 your-subgraph-name
graph deploy --node http://localhost:8020 --ipfs http://localhost:5001 your-subgraph-name