'Hardhat Config Error HH100: Network goerli doesn't exist
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.
Solution 1:[1]
I have this error in two days ago. and I can solved it with this step.
- Backup all files and folder in your project folder to.
- Delete all file and folder in your project folder and rewrite npm command.
npm init
- Generate package.json file in your folder.
npm install --save-dev hardhat @nomiclabs/hardhat-ethers "ethers@^5.0.0"
- 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.
or My git Repo smart_contract folder for example
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
