0

I am having an issue with smart contract deployment using hardhat. I don't see where is the error coming from. I have defined the .env file with values and also correctly called those values using process.env here is my hardhat.config file :

require("@nomicfoundation/hardhat-toolbox");

require('dotenv').config();

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  defaultNetwork: "goerli",
  paths: {
    artifacts: "./artifacts",

  },

  networks: {
    goerli: {
      chainId: 5,
    },
    goerli: {
      url: process.env.API_URL ,
      accounts: [process.env.PRIVATE_KEY] ,
    }
  },
  solidity: "0.8.0",
};
8
  • this is the error : Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2) Commented Nov 20, 2022 at 2:32
  • Why are you defining Goerli twice? Commented Nov 20, 2022 at 2:38
  • hi @OlivierD i was advised to add goerli chain ID, i just removed it, but still i get the error Commented Nov 20, 2022 at 2:45
  • You can add the chainId, but put it all inside one. No reason for you to have 2 “goerli”. Also, what’s in your process.env? Obviously, don’t share private keys! Commented Nov 20, 2022 at 2:50
  • so what do you think courses the error? Commented Nov 20, 2022 at 3:01

1 Answer 1

0

I believe what is happening is that the specific node you are trying to use to access the blockchain could be down or not available.... But before you assume that, try running whatever task you are doing using your local node and if it works then your online node must be down In my case, I got the error

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)

and I solved it by changing the goerli_rpc_url in my environment variable from an alchemy supplied one to one from infuria from

rpc_url=https://eth-goerli.g.alchemy.com/v2/2xAXsdfsadkflasdfaskdfhrandom

to

rpc_url=https://goerli.infura.io/v3/randomsdfkalsdfjrandom

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.