hardhat-ethers: how to get RPC URL of ethers.provider? #2309
Unanswered
aspiers
asked this question in
Troubleshooting
Replies: 1 comment 1 reply
-
Hey @aspiers,
This is unintentional and sounds like a bug. My recommended way of doing it would be |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using hardhat-ethers,
hre.ethers
is extended, and in particularhre.ethers.provider
is assigned to a provider proxy which (IIUC) wraps around the underlying Hardhat provider. However, the behaviour of this provider is not as transparent as it would be ideally. In particular,hre.ethers.provider.connection
seems to always return{ url: 'http://localhost:8545' }
regardless of what RPC URL is actually being used.I poked inside the underlying provider (
hre.ethers.provider._hardhatProvider
) and eventually managed to find the relevant connection info, but that was buried under an incredible number of layers of inheritance:Ethers apparently already hides how to discover the RPC endpoint in use, so it would be great if hardhat-ethers didn't further compound the obfuscation ;-) Apologies in advance if I'm missing something.
Beta Was this translation helpful? Give feedback.
All reactions