I'm using hardhat to auto verify my contract,
However, in await verify(simpleStorage.address, [])
, an error was reported:
Connect TimeoutError: Connect Timeout Error
const { ethers, run, network } = require("hardhat")
require("dotenv").config()
async function main() {
const contractFactory = await ethers.getContractFactory("SimpleStorage")
console.log("Deploying contract...")
const simpleStorage = await contractFactory.deploy()
await simpleStorage.deployed()
console.log("Contract deployed to:", simpleStorage.address)
console.log(network.config)
if (network.config.chainId === 11155111 && process.env.ETHERSCAN_API_KEY) {
await simpleStorage.deployTransaction.wait(6)
await verify(simpleStorage.address, [])
}
const transactionResponse = await simpleStorage.addPerson("ws", 751)
await transactionResponse.wait(1)
const favoriteNumber = await simpleStorage.retrieve("ws")
console.log(`Current value is: ${favoriteNumber}`)
}
async function verify(contractAddress, args) {
console.log("Verifying contract...")
try {
await run("verify:verify", {
address: contractAddress,
constructorArgsParams: args,
})
} catch (e) {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Already Verified!")
} else {
console.log(e)
}
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
here is my command and result:
here is my hardhat.config.js:
module.exports = {
solidity: "0.8.7",
defaultNetwork: "sepolia",
networks: {
sepolia: {
url: process.env.SEPOLIA_RPC_URL,
accounts: [process.env.SEPOLIA_PRIVATE_KEY],
chainId: 11155111,
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
}
and my package version is:
{
"name": "hardhat-simple",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "2.0.4",
"@nomiclabs/hardhat-etherscan": "^3.1.8",
"@nomiclabs/hardhat-waffle": "2.0.2",
"dotenv": "^16.3.1",
"ethers": "5.5.3",
"hardhat": "2.8.3",
"prettier": "^3.1.1",
"prettier-plugin-solidity": "^1.2.0"
}
}