-
I've mentioned this in a separate thread, but I wanted to explicitly surface it as a suggestion, and add a little context. Whilst I understand that app builders being able to pay for a premium RPC provider and supply their API keys for use in the app initially appears to be a good way to ensure people aren't going to have a poor experience from using potentially ropey public RPCs, we've actually found this has caused problems. At times of unexpectedly high demand, centralising all visitors requests through a single RPC & key has resulted in rate limiting. Furthermore, those with the know-how weren't able to bypass or relieve the issue by using their own Alchemy/Infura keys as they would be able to on other sites. Ultimately I feel there is a good case for some implementations to prefer using the RPC from an injected wallet where possible, and would really like to see this added to wagmi. In the interim I'd love to know the best way to monkey patch this in. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 19 replies
-
Totally agree! I definitely feel like there should be a way to utilise the injected wallet RPC. This has definitely been on our minds. We'll have a think about this! |
Beta Was this translation helpful? Give feedback.
-
I'd like to second this proposal. Our team was pretty surprised to find this feature not supported after moving to wagmi from an earlier version of web3-react |
Beta Was this translation helpful? Give feedback.
-
Agreed with this, calls can quickly overload smaller RPC keys, and having the flexibility to switch to the user wallet on some occasions could be nice. |
Beta Was this translation helpful? Give feedback.
-
After careful consideration, we have decided to not add the ability to switch to a wallet RPC, at least not right now. Why? It kicks down the "rate-limiting can" to the user – what if the wallet's RPC ends up getting rate-limited? It is definitely not guaranteed that every wallet user will be using their own RPC endpoints & API keys. In fact, most users would be using public RPC endpoints – which are more vulnerable to rate-limiting. The dapp will have no longer have control over the RPC In the short term, we highly recommend configuring chains with multiple providers via configureChains – this allows the dapp to fall back to another provider when something goes wrong (ie. provider has reached their quota). In the long term, we definitely want to have a more robust solution around dealing with multiple RPC providers, and minimizing side-effects that emit unneeded/redundant RPC requests – we are working on this! UPDATE: |
Beta Was this translation helpful? Give feedback.
-
Did it just got implemented in #1406? |
Beta Was this translation helpful? Give feedback.
-
I was also in this situation recently and found this ongoing discussion, I understand the logic behind the wagmi team decision and agree with the points raised by @jxom, can't wait for how they solve it in future versions. But also, I still wanted to monkey patch it for now, I hope they don't get mad at me for sharing how I did it. Simply put, extending on what @tmm wrote above, I copied the You can see a code example below, use it at your own risk as this will probably break depending on what wallet you allow users to connect with and what your project is trying to do.
|
Beta Was this translation helpful? Give feedback.
-
Wagmi v2 will support using an Injected Wallet's RPC: https://beta.wagmi.sh/react/api/transports/unstable_connector |
Beta Was this translation helpful? Give feedback.
Wagmi v2 will support using an Injected Wallet's RPC:
https://beta.wagmi.sh/react/api/transports/unstable_connector