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.

Dominik
  • 123
  • 1
  • 1
  • 6

7 Answers7

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0
[`0x${PrivateKey}`]

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

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Astha
  • 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. – Jeremy Caney Jul 19 '22 at 08:10
0

you are importing the wrong thing. It should be:

import type { HardhatUserConfig } from "hardhat/types";
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
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']
    } 
  }
}
S SANTOSH
  • 21
  • 1
  • 6
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}`]
    }
  }
};
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.

-1

issue is regarding:

defaultNetwork: "yourtestnetname",

but , No support for goearli

You can use polygon : mumbai testnet

Brijmohan Karadia
  • 437
  • 1
  • 5
  • 10