HardHat 和 Rinkeby ProviderError:必须经过身份验证错误

问题描述 投票:0回答:3

当我跑步时

npx hardhat console --network rinkeby 

accounts = await ethers.provider.listAccounts();

我明白了

未捕获的提供商错误:必须经过身份验证!

hardhat.config.js 中有以下 rinkeby 网络配置

rinkeby: {
  url: "ALCHEMY_URL",
  accounts:["YOUR_PRIVATE_KEY"],
}
ethereum hardhat
3个回答
3
投票

解决方案:使用以下行更新配置文件:

rinkeby: {
        url: "ALCHEMY_URL",
        accounts: ["YOUR_PRIVATE_KEY"],
        gas: 2100000,
        gasPrice: 8000000000,
        saveDeployments: true,
    }

这就像一个魅力。希望这有助于节省您的一些时间。


0
投票

最后,你的

hardhat.config.js
应该看起来像这样

require('@nomiclabs/hardhat-waffle');

module.exports = {
  solidity: '0.8.0',
  networks: {
    ropsten: {
       url: `${ARCHEM_APP_URL}`,
       accounts: [`${ACCOUNT_KEY}`],
       gas: 2100000,
       gasPrice: 8000000000,
       saveDeployments: true,
    }
  }
}

0
投票

您的提供商 URL 有问题,请先尝试不使用 env。会起作用的

© www.soinside.com 2019 - 2024. All rights reserved.