【问题标题】:config error : Invalid value undefined for HardhatConfig.networks.paths.url配置错误:未定义 HardhatConfig.networks.paths.url 的无效值
【发布时间】:2022-07-26 01:33:26
【问题描述】:

这是我的 hardhat.config.js 文件代码:

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

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  solidity: "0.8.4",
  networks : {
    hardhat :{
      chainId: 1337,
    },
  
  paths :{
    artifacts: "./src/artifacts",
  },
},
};

当我使用 npx hardhat compile 编译它时

它显示以下错误:

错误 HH8:您的配置文件中有一个或多个错误:

  • 为 HardhatConfig.networks.paths.url 定义的值无效 - 需要类型的值 字符串。

想了解更多关于Hardhat的配置,请到https://hardhat.org/config

供您参考,我正在按照本教程构建这个 web3 项目:“https://blog.suhailkaka.com/setup-and-build-your-first-web-3-application”

【问题讨论】:

    标签: javascript blockchain solidity web3js hardhat


    【解决方案1】:

    你必须在安全帽链 ID 之后关闭网络的括号:)

    请用这个替换你的 module.exports 对象

    module.exports = {
      solidity: "0.8.4",
      networks:{
        hardhat:{
          chainId: 1337,
        }
      },
      paths:{
        artifacts: "./src/artifacts"
      }
    };
    

    P.S:谢谢指出,我的文章也更新了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      • 1970-01-01
      • 2018-12-14
      • 2020-09-05
      • 2019-04-30
      • 2022-12-10
      • 2020-02-01
      相关资源
      最近更新 更多