0

I am trying to connect an Ethereum node which is outside of my organisation. So that's why I need to use a proxy agent to connect external URLs.

I am looking for a way to configure the proxy agent while setting up the ethers.js provider.

Say my ethereum node is: https://ropsten.infura.io/v3/xxxxxx and proxy is myproxy-network.com:80.

I already did this using web3.js and HttpProvider, which works but have to move with ethers.js due to business needs. The web3.js example is shown below -

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))

Need help to do something similar with ethers.js.

1 Answer 1

1

The answer will dissapoint you. Cause there is still no method or option to add custom http agent through the ether.js.

There had been a PR and the developer said he might add it in ethersV5 but surely in ether.js version 6.

I guess you have to wait until the release of v6 before using this function. The current version is 5.6.

PR: Add support for custom http.agent.

1
  • 1
    For now, web3.js is the only way then! Thanks
    – DIGVJSS
    Commented Sep 16, 2022 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.