Ganache

無法部署到 Graph 節點:註冊商不支持乙太坊網路:主網

  • August 18, 2021

我在圖形文件上遵循了本教程:https ://thegraph.com/docs/quick-start#local-development

但是,我在執行後收到一條錯誤消息yarn deploy-local

Failed to deploy to Graph node http://127.0.0.1:8020/: Ethereum network not supported by registrar: mainnet

我在這裡有什麼遺漏嗎?

這是整個日誌

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 specVersion from 0.0.1 to 0.0.2
✔ Apply migrations
⚠ Warnings loading subgraph from subgraph.yaml: Warnings in subgraph.yaml:
 
   Path: repository
   The repository is still set to https://github.com/graphprotocol/example-subgraph.
   Please replace it with a link to your subgraph source code.
 
   Path: description
   The description is still the one from the example subgraph.
   Please update it to tell users more about your subgraph.

✔ Load subgraph from subgraph.yaml
 Compile data source: Gravity => build/Gravity/Gravity.wasm
✔ Compile subgraph
 Copy schema file build/schema.graphql
 Write subgraph file build/Gravity/abis/Gravity.json
 Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/
 Add file to IPFS build/schema.graphql
               .. QmbSFRGGvHM7Cn8YSjDL41diDMxN4LQUDEMqaa5VVc5sC4
 Add file to IPFS build/Gravity/abis/Gravity.json
               .. QmajZTadknSpgsCWRz9fG6bXFHdpVXPMWpx9yMipz3VtMQ
 Add file to IPFS build/Gravity/Gravity.wasm
               .. QmbK8bwncci52cstF3P8Q8i4oGjrMt1pUqdv5Uf1VXqXdb
✔ Upload subgraph to IPFS

Build completed: QmYc13fDLwyvTT5crdGWGuFbaN23YxJ8RG8EGNW4Bac24j

✖ Failed to deploy to Graph node http://127.0.0.1:8020/: Ethereum network not supported by registrar: mainnet
error Command failed with exit code 1.

更新:這是我的subgraph.yaml

specVersion: 0.0.2
description: Gravatar for Ethereum
repository: https://github.com/graphprotocol/example-subgraph
schema:
 file: ./schema.graphql
dataSources:
 - kind: ethereum/contract
   name: Gravity
   network: mainnet
   source:
     address: '0x2E645469f354BB4F5c8a05B3b30A929361cf77eC'
     abi: Gravity
   mapping:
     kind: ethereum/events
     apiVersion: 0.0.4
     language: wasm/assemblyscript
     entities:
       - Gravatar
     abis:
       - name: Gravity
         file: ./abis/Gravity.json
     eventHandlers:
       - event: NewGravatar(uint256,address,string,string)
         handler: handleNewGravatar
       - event: UpdatedGravatar(uint256,address,string,string)
         handler: handleUpdatedGravatar
     file: ./src/mapping.ts

錯誤消息“註冊商不支持乙太坊網路:主網”可能會產生誤導,至少在我的情況下是這樣。我收到此錯誤是因為我已經hardhat node在主機上執行,但不是在主機上執行--hostname 0.0.0.0,並且我認為同樣適用於ganache-cli.

由於graph-nodeDocker 容器被配置為在 Docker 內部網路上查找以主機 IP 地址命名的乙太坊網路mainnet,因此它看不到hardhat node正在偵聽的127.0.0.1. 所以真正的錯誤不是不支持“主網”,而是無法訪問為“主網”配置的 IP 地址。跑步hardhat node --hostname 0.0.0.0成功了。

在本地執行圖形節點時, insubgraph.yamlnetwork值應該是mainnet,這在文件中並不清楚。

從這篇很棒的 dapp-development-with-a-local-subgraph文章中,

subgraph.yml 文件中定義的所有合約的網路必須是主網,即使您正在部署到本地節點。這不會與乙太坊主網路互動——這只是 subgraph.yml 需要為您的本地節點配置的方式。我學得很辛苦……

引用自:https://ethereum.stackexchange.com/questions/99409