我正在尝试连接一个Ethereum节点,它在我的组织之外。因此,我需要使用代理代理来连接外部URL。
我正在寻找一种在设置ethers.js提供程序时配置代理代理的方法。
假设我的ethereum节点是:https://ropsten.infura.io/v3/xxxxxx,而代理是myproxy-network.com:80。
我已经使用web3.js和HttpProvider完成了这一工作,但由于业务需要,必须使用ethers.js。web3.js示例如下所示-
const tunnel = require('tunnel')
const Web3 = require('web3')
const options = {
keepAlive: true,
timeout: 20000,
agent: {
https: tunnel.httpsOverHttp({
proxy: {
host: 'myproxy-network.com',
port: 80
}
})
}
}
const web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/v3/xxxxxx', options))需要帮助对ethers.js做一些类似的事情。
发布于 2022-09-16 10:00:44
答案会让你失望的。因为仍然没有通过ether.js添加自定义http代理的方法或选项。
曾经有过公关,开发人员说他可能会在ethersV5中添加它,但肯定会添加到ether.js版本6中。
我想您必须等到v6发布后才使用此函数。目前的版本是5.6。
https://ethereum.stackexchange.com/questions/135726
复制相似问题