# 编程日记:Hardhat合约验证(2022-08-30) **Published by:** [Corror](https://paragraph.com/@corror/) **Published on:** 2022-08-30 **URL:** https://paragraph.com/@corror/hardhat-2022-08-30 ## Content 编程学习做了什么?成功写出了验证智能合约的代码,但是在运行时出现了报错。收获了什么?尝试解决验证失败的问题我的 verify 函数声明:async function verify(contractAddress, args) { try { /**About "verify:verify": * The first verify is a name in the type of string * The second verify is the task of verify */ await run("verify:verify", { address: contractAddress, constructorArgument: args, }) } catch (e) { /**Why we need a try... catch.. here? * To throw the error if the verification get wrong. */ if (e.message.toLowerCase().includes("already verified")) { console.log("Already Verified!") } else { console.log(e) } } } 我的 verify 函数调用:await verify(simpleStorage.address, []) 我的报错: 🔻第一次报错 第一次验证时,出现了如下报错:ENOENT: no such file or directory 🔻第二次报错 谷歌搜索后,根据最高赞回答,尝试了 npx hardhat clean 命令,擦除了 cache, 结果直接导致无法科学上网,并出现了以下报错:Endpoint URL: https://api-rinkeby.etherscan.io/api Reason: Connect Timeout Error 根据登链社区的回答以及CSDN的回答,是因为我们无法访问 EtherScan 的 API, 个人推测是域名污染问题。 同时,由于 WSL 也读取的是 Windows 当中的 hosts 文件,因此,我们需要在本地的 [hosts](https://etherscan.io/address/) 文件中,针对 etherscan.io 这个域名添加一行映射:104.22.14.57 api-rinkeby.etherscan.io 在配置过后,ping api-rinkeby.etherscan.io 确实可以成功访问,但是问题依然存在... ## Publication Information - [Corror](https://paragraph.com/@corror/): Publication homepage - [All Posts](https://paragraph.com/@corror/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@corror): Subscribe to updates