Lesson 6 : Contract not verifying #2892
-
Hi, Deploying Contract Please wait..... No verification is done. My code for deploy.js is below const { ethers, run, network } = require("hardhat")
//async main
async function main() {
const SimpleStorageFactory = await ethers.getContractFactory(
"SimpleStorage"
)
console.log("Deploying Contract Please wait.....")
const simpleStorage = await SimpleStorageFactory.deploy()
await simpleStorage._deployed()
console.log(`Deployed Contract to: ${simpleStorage.address}`)
if (network.config.chainId === 5 && process.env.ETHERSCAN_API_KEY) {
console.log(`Waiting for block confirmations....`)
await simpleStorage.deployTransaction.wait(6)
await verify(simpleStorage.address, [])
}
//interacting with the contract
const currentValue = await simpleStorage.retrieve()
console.log(`Current Value is : ${currentValue}`)
//updating the favorite number in our contract
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) {
const verify = async (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)
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey @nishaniyaz are you sure you were deploying with the flag |
Beta Was this translation helpful? Give feedback.
-
Push to GitHub. |
Beta Was this translation helpful? Give feedback.
Hey @nishaniyaz are you sure you were deploying with the flag
--network goerli
? if not, please make sure you do so. And also check your hardhat.config.js file in the networks section if you have setchainId
for goerli to5