Skip to content
Advertisement

Error HH8: There’s one or more errors in your config file: * Invalid account: #0 for network: mumbai – Expected string, received undefined

Error HH8: There’s one or more errors in your config file:

  • Invalid account: #0 for network: mumbai – Expected string, received undefined
  • Invalid account: #0 for network: mainnet – Expected string, received undefined

To learn more about Hardhat’s configuration, please go to https://hardhat.org/config/

Neither two previous answers worked for me: * Invalid account: #0 for network: mumbai – Expected string, received undefined H88 Error: Invalid account: #0 for network: mumbai – Expected string, received undefined

Ended up with same error as before.

This is my hardhat.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
      }
    }
  }
}; ```

Advertisement

Answer

Posting an update to my own question. I checked my .secret file again. I had messed up with the format there by having pressed enter too many times. It was reading it as “extra characters” when it is supposed to be exactly 32 bytes(64 characters). Super rookie mistake. Thank you to those that tried to help me.

Advertisement