在hardhat中加入hardhat.config.js中加入如下代码即可。出处https://github.com/lxdao-official/gclx-contracts/issues/2const{setGlobalDispatcher,ProxyAgent}=require("u
在hardhat中加入hardhat.config.js中加入如下代码即可。
出处https://github.com/lxdao-official/gclx-contracts/issues/2

const {setGlobalDispatcher,ProxyAgent} = require("undici")
const proxyAgent = new ProxyAgent('http://127.0.0.1:4780')
setGlobalDispatcher(proxyAgent)
例子:
require("dotenv").config(); //给验证合约设置代理 const {setGlobalDispatcher,ProxyAgent} = require("undici") const proxyAgent = new ProxyAgent('http://127.0.0.1:4780') setGlobalDispatcher(proxyAgent) /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { defaultNetwork: "goerli", etherscan: { apiKey: process.env.ETHERSCAN_API_KEY, // 在 etherscan 中设置 API 密钥 // 增加超时时间(以毫秒为单位) timeout: 600000, // 设置为 10 分钟的超时 }, networks: { // 4. Add the Moonbase Alpha network specification goerli: { url: 'https://rpc.ankr.com/eth_goerli', chainId: 5, accounts: [process.env.BASE_GOERLI_PRIVATE_KEY] }, }, solidity: { version: "0.8.9", settings: { optimizer: { enabled: true, runs: 200 } } }, };
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!