3

Looked everywhere, and all I can find are a bunch of EIPs. Is there a document/repo somewhere listing all available RPC calls that interact with the wallet (wallet_...)?

Specifically, I'd like to switch a user to one of the testnets when they log into my dApp. However, wallet_addEthereumChain, mentioned in EIP-3085 does not work for mainnet, or any of the 4 testnets (returns May not specify default MetaMask chain.), and wallet_updateEthereumChain mentioned in EIP-2015, returns May not specify default MetaMask chain. as well.

3

The docs you're looking for can be found on the Metamask site: https://docs.metamask.io/guide/rpc-api.html#table-of-contents

The RPC call you're looking for is indeed wallet_addEthereumChain(), which you've tried.

The restriction you're hitting is by design: according to the docs the call won't work... "If the chain ID corresponds to any default MetaMask chains."

However, there's an open issue tracking the potential removal of the check: #10597.

2
  • Thanks! That's what I needed. Seems like these are MetaMask specific? Do other Web3 wallets subscribe to the same RPC calls, and have the same effects? – Traveling Tech Guy Mar 23 at 17:59
  • 1
    Hi again - yes, these are Metamask specific. I think different wallets (i.e. providers, when you've incorporated them into your code) will have their own RPC methods. The one you've used was only added by Metamask about 10 days ago. I don't know of any other provider that lets you push the user to an alternative network via an RPC method. – Richard Horrocks Mar 23 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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