解决 Hardhat 因为特殊原因 verify 失败
解决方案
问题背景
今天在学习使用Hardhat进行verify 合约 到 Ethscan的时候,出现了如下报错
fafa@fafadeMacBook-Air Web3_Solidity_Study % npx hardhat verify --network sepolia XXXXXXXXXXXXXXXXXXXXXXXX "10"
Successfully verified contract FundMe on Sourcify.
https://repo.sourcify.dev/contracts/full_match/11155111/XXXXXXXXXXXXXXXXXXXXXXXXX/
hardhat-verify found one or more errors during the verification process:
Etherscan:
A network request failed. This is an error from the block explorer, not Hardhat. Error: Connect Timeout Error
从这个报错信息中,可以看出是超时问题,一般超时问题是网络原因导致的。
解决方案
参考:https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/2247#discussioncomment-5496669
Windows
局域网
终端:
在 hardhat.config.js 中添加以下代码:
const { ProxyAgent, setGlobalDispatcher } = require("undici");
const proxyAgent = new ProxyAgent("http://127.0.0.1:7890");
setGlobalDispatcher(proxyAgent);
以上代码用来告诉程序按照本地代理链接网络。
记得安装undici 依赖包:
npm install --save-dev undici
Mac
mac设置LAN的方式如下,按照我下面这张图即可
————————————————
原文链接:https://blog.csdn.net/a648119398/article/details/143468584
内容来自转载,如有不妥,请联系下架。