【问题标题】:Error connecting to localhost after npm hardhat run it shows network lostnpm hardhat 运行后连接到 localhost 时出错,显示网络丢失
【发布时间】:2022-10-20 12:22:15
【问题描述】:

我是使用安全帽部署智能合约的新手,并且正在学习教程。但是,在运行 const contract = await ethers.getContractAt("Decentratwitter","0x5FbDB2315678afecb367f032d93F642f64180aa3") 后,我收到以下错误。关于如何解决连接问题的任何想法?

avinash@avinash-HP-Laptop-15-bw0xx:~$ cd twitter

avinash@avinash-HP-Laptop-15-bw0xx:~/twitter$ npx hardhat run scripts/deploy.js --network hardhat Decentratwitter 部署到:0x5FbDB2315678afecb367f032d93F642f64180aa3 avinash@avinash-HP-Laptop-15-bw0xx:~/twitter$ npx 安全帽控制台 --network localhost 欢迎使用 Node.js v14.19.3。 键入“.help”以获取更多信息。

常量合约 = 等待 ethers.getContractAt("Decentratwitter","0x5FbDB2315678afecb367f032d93F642f64180aa3") 未捕获的 HardhatError:HH108:无法连接到网络 localhost。 请确保您的节点正在运行,并检查您的互联网连接和网络配置 在 getContractAtFromArtifact (/home/avinash/twitter/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:337:19) 在 getContractFactoryByAbiAndBytecode (/home/avinash/twitter/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:280:21) 在 getSigners (/home/avinash/twitter/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:45:20) 在 EthersProviderWrapper.send (/home/avinash/twitter/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20) 在 GanacheGasMultiplierProvider.request (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:306:23) 在 GanacheGasMultiplierProvider._isGanache (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:317:30) 在 HttpProvider.request (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/http.ts:80:29) 在 processTicksAndRejections (internal/process/task_queues.js:95:5) 在 HttpProvider._fetchJsonRpcResponse (/home/avinash/twitter/node_modules/hardhat/src/internal/core/providers/http.ts:205:15)

Caused by: Error: connect ECONNREFUSED 127.0.0.1:8545
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:130:17)

【问题讨论】:

    标签: ethereum hardhat


    【解决方案1】:
    1. 在终端中运行npx hardhat node。让进程继续运行。
    2. 打开一个新的终端窗口。
    3. 运行npx hardhat run [script-name] --network localhost

      希望能帮助到你!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-02
      • 1970-01-01
      • 2017-11-06
      • 2017-06-17
      • 1970-01-01
      • 2015-12-27
      • 2014-09-03
      相关资源
      最近更新 更多