* Invalid value undefined for HardhatConfig.networks.goerli.url - Expected a value of type string

91 views Asked by At

I want to compile my contract using npx hardhat compile. However, i am getting this error.

  • Invalid value undefined for HardhatConfig.networks.goerli.url - Expected a value of type string.
  • Invalid account: #0 for network: goerli - Expected string, received undefined

Here is my code in hardhat config file. I have already installed dotenv pacakage and used the process.env to call my private key and url.

require("@nomicfoundation/hardhat-toolbox");
require('dotenv').config();

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.19",
  networks: {
    goerli: {
      url: process.env.ALCHEMY_TESTNET_RPC_URL,
      accounts: [process.env.TESTNET_PRIVATE_KEY],
    },
  },
};
1

There are 1 answers

0
schaable On

Your code looks good at first glance. I'd suggest putting the url string directly instead of the environment variable and see if you get a different error. If you do, there's something wrong with your dotenv setup.