Hardhat compile error "expected a value of type HttpNetworkConfig"
P粉200138510
P粉200138510 2023-10-30 19:02:05
0
1
761

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粉200138510
P粉200138510

reply all(1)
P粉834840856

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!