错误HH8:配置文件中有一个或多个错误
- 网络的无效帐户#0:mumbai-应为字符串,收到的未定义
- 网络的无效帐户#0:mainnet-应为字符串,收到的未定义
若要了解更多有关Hardhat配置的信息,请访问https://hardhat.org/config/
之前的两个答案对我都不起作用:*无效的帐户#0用于网络:mumbai-应为字符串,收到的未定义H88错误:网络的账号#0无效:mumbai-应为字符串,收到未定义的
最后出现了和以前相同的错误。
这是我的硬盘。config.js:
const fs = require('fs'); //allow to read from local file system
const projectId = fs.readFileSync(".secret").toString().trim() || "";//kept real source code of "projectId" out for this question asking
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 1337
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${projectId}`,
url: "https://rpc-mumbai.matic.today",
accounts: [process.env.privateKey]
},
mainnet: {
url: `https://polygon-mainnet.infura.io/v3/${projectId}`,
url: "https://polygon-rpc.com/",
accounts: [process.env.privateKey]
},
},
solidity: {
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
}; ```
发布我自己问题的更新。我再次检查了我的.secret文件。我按了太多次回车键,把格式搞砸了。它把它读成";额外字符";当它应该正好是32字节(64个字符(时。超级新手失误。感谢那些试图帮助我的人。