-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide useRPC
hook to allow dynamic change of RPC provider
#282
Comments
useRPC
hook to allow dynamic change of RPC provider
+1 |
If I understand you would like to dynamically change rpc provider? You can do that via useUpdateConfig: const updateConfig = useUpdateConfig()
updateConfig({readOnlyUrls: {[ChainId.Mainnet]: '...'}) |
Hi @tt-marek. Is there a way to substitute the JsonRPCProvider with either Infura or Static provider from ethers via configuraiton? Linking #356 as well. Here's an issue on ethers.js describing why Static or Infura would avoid the unnecessary ChainID calls. ethers-io/ethers.js#901 |
A yeah, that we would need to introduce as a new item in the config.... |
Awesome. Thank you! @tt-marek Are you able to suggest how I might change this globally prior to it being a config option? I've tried to trace where the provider is set but have not been able to crack that nut. |
So I was looking for web3-react to be using one of the ethers.js providers but they're not. From what I can gather, it's most likely FrameConnector or InjectedConnector that's doing the offending Edit: After digging around for a few hours, I believe the problem might be legitimate calls for eth_ChainId to infura when using the read only connector. It would be ideal to not query Infura for ChainId but instead read it from the currently set readOnlyChainId. Still just a hunch, but not giving up on this. |
Gotcha, indeed, that's what I was looking for and I missed in the documentation. In my particular case, I had The new configuration proposal in #409 seems to make this way more obvious, so we can take this conversation there and close this particular issue. FWIW I'm happy this issue highlighted @jhirn 's issue as in other project we had to replace the |
@0xjjpa with the latest version you can pass a provider instance (compatible with |
Bug or feature?
Feature
What issue is this feature related to?
Multiple DApps come embedded with their own RPC providers like Infura, Quiknode, or Alchemy for them to work. This is mostly to avoid the UX experience of having to connect to Metamask before they can show any information. However, as a result, the DApp developer has to foot the bill on the provider used, share its credentials in the UI, and make the decision on the provider used by the final user, sadly affecting the user's privacy (i.e. most providers do IP tracking). Yes, there are public providers like LinkPool or other community-oriented projects like RYO Cloud, but usually, the user is not given any option to change these.
What's the feature you would like?
A hook a la
useRPC
that would allow to configure the RPC endpoint used for the DApp and reload the state of the application upon update. As I'm unsure how these would affect other providers, I'm bringing this feature here rather than just doing it solo.What alternatives you have considered?
This is already somehow possible with the custom hooks feature, but it would be nice to have it OOB as part of
useDApp
Additional context
The current practice for frontends is to embed an RPC endpoint, whitelist the contract used, and hope no one will exhaust it via some
eth_getBalance
calls. This could be a good step in a better direction.The text was updated successfully, but these errors were encountered: