修复hardhat发布合约代码出错的问题

hardhat-verify found one or more errors during the verification process:

Etherscan: An unexpected error occurred during the verification process. Please report this issue to the Hardhat team. Error Details: Connect Timeout Error


  1. npm install –save-dev undici

  2. 在 hardhat.config.js 中添加以下代码:

const { ProxyAgent, setGlobalDispatcher } = require("undici");
const proxyAgent = new ProxyAgent("http://127.0.0.1:7890");
setGlobalDispatcher(proxyAgent);

Reference:

https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/2247#discussioncomment-5496669