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 :


/** @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",
}; ```
  • this is the error : Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2) Nov 20 at 2:32
  • Why are you defining Goerli twice?
    – OlivierD
    Nov 20 at 2:38
  • hi @OlivierD i was advised to add goerli chain ID, i just removed it, but still i get the error Nov 20 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!
    – OlivierD
    Nov 20 at 2:50
  • so what do you think courses the error? Nov 20 at 3:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.