search

Home  >  Q&A  >  body text

Hardhat compile error "expected a value of type HttpNetworkConfig"

I'm trying to follow the NFT tutorial here. I've set up an account on Alchemy and Metamask created the .sol file. I have a .env file in my root directory that looks like this:

API_URL = "https://eth-ropsten.alchemyapi.io/v2/your-api-key"
PRIVATE_KEY = "your-metamask-private-key"

My hard hat configuration file looks like this:

/**

* @type import('hardhat/config').HardhatUserConfig

*/

require('dotenv').config();

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

const { API_URL, PRIVATE_KEY } = process.env;

module.exports = {

   solidity: {
      compilers: [
        {
          version: "0.5.7"
        },
        {
          version: "0.8.0"
        },
        {
          version: "0.6.12"
        }
      ]
    },

   defaultNetwork: "ropsten",

   networks: {

      hardhat: {},

      ropsten: {

         url: API_KEY,

         accounts: [`0x${PRIVATE_KEY}`]

      }

   },

}

However, when I try to compile, I keep getting this error:

Invalid value {"url":"https://eth-ropsten.alchemyapi.io/v2/your-api-key","account":["0xyour-metamask-private-key"]} For HardhatConfig.networks.ropsten - type value required HttpNetworkConfig.

I can't seem to figure out why this is not a valid value for HttpNetworkConfig. What I have where url is a string and accounts is an array seems to match what is in the network configuration documentation. This is a compilation error, so it doesn't look like it can be an issue with the actual URL or the private key, but maybe I'm wrong. I'm willing to admit that I'm a noob with only a cursory understanding of hardhat, reliability, and even js, etc. Thanks for any help.

P粉200138510P粉200138510434 days ago946

reply all(1)I'll reply

  • P粉834840856

    P粉8348408562023-10-31 12:54:23

    As it turns out, the problem was with my private key. check carefully.

    reply
    0
  • Cancelreply