Lesson 6: Trying to deploy "yarn hardhat run scripts/deploy.js --network sepolia " but keep getting an error #5484
Answered
by
Nlferu
TheyAskWho
asked this question in
Q&A
-
Hi, I'm new to coding, I was working on my code but I ended up with getting an error every time I tried deploying
anyone know what could be the problem? I seen few questions asked online about a similar issue but didn't work for me hardhat.config.js require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config()
require("@nomiclabs/hardhat-etherscan")
/** @type import('hardhat/config').HardhatUserConfig */
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
module.exports = {
solidity: "0.8.8",
defaultNetwork: "hardhat",
networks: {
hardhat: {},
Sepolia:{
url: SEPOLIA_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 11155111,
},
},
solidity: "0.8.8",
etherscan: {
apiKey: ETHERSCAN_API_KEY,
}
};
deploy.js // imports
const { ehters, run, network } = require("hardhat")
// async main
async function main() {
const SimpleStorageFactory = await ethers.getContractFactory(
"SimpleStorage"
)
console.log("Deploying contract...")
const simpleStorage = await SimpleStorageFactory.deploy()
await simpleStorage.deployed()
console.log(`Deployed contract to: ${simpleStorage.address}`)
if (network.config.chainId === 11155111 && process.env.ETHERSCAN_API_KEY) {
await simpleStorage.deployTransaction.wait(6)
await verify(simpleStorage.address, [])
}
const currentValue = await simpleStorage.retrieve()
console.log(`Current Value is: ${currentValue}`)
// Update the current value
const transactionResponse = await simpleStorage.store(7)
await transactionResponse.wait(1)
const updatedValue = await simpleStorage.retrieve()
console.log(`updated Value is: ${updatedValue}`)
}
async function verify(contractAddress, args) {
console.log("Verifying contract...")
try {
await run("verify:verify", {
address: contractAddress,
constructorArguments: args,
})
} catch (e) {
if (e.message.toLowerCase().includes("already verified")){
console.log("Already Verified!")
} else {
console.log(e)
}
}
}
// main
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); Error Error HH100: Network sepolia doesn't exist |
Beta Was this translation helpful? Give feedback.
Answered by
Nlferu
May 14, 2023
Replies: 1 comment 1 reply
-
Hello @TheyAskWho Please change your require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config()
require("@nomiclabs/hardhat-etherscan")
/** @type import('hardhat/config').HardhatUserConfig */
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
module.exports = {
solidity: "0.8.8",
defaultNetwork: "hardhat",
networks: {
hardhat: {},
// Just rename it from Sepolia into sepolia
sepolia:{
url: SEPOLIA_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 11155111,
},
},
solidity: "0.8.8",
etherscan: {
apiKey: ETHERSCAN_API_KEY,
}
};
and also check if your const networkConfig = {
31337: {
name: "localhost",
},
11155111: {
name: "sepolia",
},
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
TheyAskWho
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @TheyAskWho
Please change your
hardhat.config.js
into below: