Hardhat Config Error HH100: Network goerli doesn't exist
Asked Answered
A

7

8

I am trying to deploy a contract on Goerli, but I constantly get the error Error HH100: Network goerli doesn't exist

Here is my hardhat.config.ts

require("dotenv").config();
import { task } from 'hardhat/config';
import '@nomiclabs/hardhat-waffle';
import '@typechain/hardhat'
import '@nomiclabs/hardhat-ethers';
import { HardhatUserConfig } from "hardhat/config";


const PrivateKey = "b427...";

const config: HardhatUserConfig = {
  solidity: {
        version: '0.8.0',
        },
  networks: {
        goerli: {
                chainId: 5,
                url: "https://goerli.infura.io/v3/309820d3955640ec9cda472d998479ef",
                accounts: [PrivateKey],
        },
  },
 };

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
export default {
  solidity: '0.8.0',
};

Thanks!

I don't know what I should add more, but please just ask and I will post more information.

Artificiality answered 16/2, 2022 at 19:0 Comment(3)
did you try the answer?Guth
what was the command that you ran to try to deploy to Goerli?Aggrieved
in my case I had set defaultNetwork to goerli but hadn't updated the networks section to contain it (it was preset to ropsten).Myiasis
U
2

I have this error in two days ago. and I can solved it with this step.

  1. Backup all files and folder in your project folder to.
  2. Delete all file and folder in your project folder and rewrite npm command.

npm init

  1. Generate package.json file in your folder.

npm install --save-dev hardhat @nomiclabs/hardhat-ethers "ethers@^5.0.0"

  1. Choose.

Create an empty hardhat.config.js

Now your project is install hardhat. and create copy all folder in backup folder and solidity code to your project folder But if you have artifacts and cache folder don't copy it.

And in hardhar.config.js file paste this code on the top.

require('@nomiclabs/hardhat-ethers')
const API_URL = "Your testnet rpc link";
const PRIVATE_KEY = "Your Private Accout address"
const PUBLIC_KEY = "Your Account Address";

and in module.module export code here.

module.exports = {
  solidity: "0.8.0",
  defaultNetwork: "yourtestnetname",
  networks: {
    hardhat:{},
    yourtestnetname:{
      url: API_URL,
      accounts: [`0x${PRIVATE_KEY}`]
    }
  }
};

Check 0x${} for sure it in your PRIVATE_KEY. Then use this command

npx hardhat compile

if Compile is success folder artifacts and cache will generate in your project and Generate smart contract code. And copy code in your backup deploy.js file.

Now deploy.js file with this command

npx hardhat run scripts/deploy.js --network yournamenetwork

if compile success your terminal will show your contract address

You can check this video tutorial right here.

Deploy Smart Contract.

or My git Repo smart_contract folder for example

Git Repo.

Uncap answered 24/2, 2022 at 3:9 Comment(0)
C
0
[`0x${PrivateKey}`]

Check 0x${} to be sure it is in your PRIVATE_KEY.

Coulter answered 12/7, 2022 at 18:33 Comment(1)
Please be careful about repeating answers. If the same answer can solve multiple questions without any modifications, consider flagging one of the questions as a duplicate. Otherwise, consider customizing your answer to better address the specifics of the question.Luddite
C
0

you are importing the wrong thing. It should be:

import type { HardhatUserConfig } from "hardhat/types";
Clothe answered 23/11, 2022 at 21:10 Comment(0)
I
0

You shouldn't gave me a file named

deploy.js

But if you found the correct code through this documentation Ethereum.org.
some example about js:
your deploy.js file should be

   async function main() {
   const [deployer] = await ethers.getSigners();

   console.log("Deploying contracts with the account:", deployer.address);

   console.log("Account balance:", (await deployer.getBalance()).toString());

   const Token = await ethers.getContractFactory("Transaction");
   const token = await Token.deploy();

   console.log("Token address:", token.address);
   }

   main()
   .then(() => process.exit(0))
   .catch((error) => {
    console.error(error);
    process.exit(1);
   });

your hardhat.config.js file should be


require('@nomiclabs/hardhat-waffle')

module.exports = {
  solidity : 'version',
  networks : {
    goerli : {
      url : 'alchemy_url',
      accounts : ['private_key']
    } 
  }
}
Ineligible answered 30/12, 2022 at 18:1 Comment(0)
R
0

Even i Had a same error. 1.first of all initializes the process again with. yarn init or npm init 2.Install all the dependencies required for the program to run yarn add --dev hardhat 3.Then go to hardhatconfig.js , in import section paste this code

require('@nomiclabs/hardhat-ethers')
const API_URL = "Your testnet rpc link";// from your testet provider
const PRIVATE_KEY = "Your Private Accout address"
const PUBLIC_KEY = "Your Account Address";

below :-

solidity
module.exports = {
  solidity: "0.8.0",
  defaultNetwork: "yourtestnetname",
  networks: {
   hardhat:{},
   sepolia:{
   url: API_URL,
   accounts: [`0x${PRIVATE_KEY}`]
    }
  }
};
Renae answered 19/4, 2023 at 8:30 Comment(0)
P
0

I had a similar problem but in my case I was running my node on Alchemy, I created a new App(Project) which generated a new API KEY and most importantly a new http end point which I then passed to my RPC_URL variable, the damn thing worked after an hour of checking out my code for possible errors without finding any.

Piaffe answered 28/5, 2023 at 17:29 Comment(1)
What do you mean exactly by "a new http endpoint" in your case?Cordate
G
-1

issue is regarding:

defaultNetwork: "yourtestnetname",

but , No support for goearli

You can use polygon : mumbai testnet

Grapevine answered 12/12, 2022 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.