Provide `useRPC` hook to allow dynamic change of RPC provider
See original GitHub issueBug 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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:8 (3 by maintainers)
@0xjjpa with the latest version you can pass a provider instance (compatible with
BaseProvider
from ethers) to thereadOnlyUrls
instead of the URL. This should let you use custom provider types, and configure the refresh interval on them+1