EIP-3326 Wallet chain-switching method (Wallet Switch Ethereum Chain RPC Method (`wallet_switchEthereumChain`))
No call decision · Other · EIP status Stagnant · created 2021-03-04
Defines wallet_switchEthereumChain, an RPC method that lets a dapp request that a wallet switch the active Ethereum chain.
Why it is needed
Some wallets have an active-chain concept, forwarding requests to only one chain at a time. Until now, when a dapp needed to operate on a chain different from the one the wallet was currently connected to, the user had to switch chains manually in the wallet UI. This process is cumbersome for users, and there is a risk that if a user forgets to switch and approves a transaction, they end up acting on an unintended chain. wallet_switchEthereumChain reduces this manual switching process by letting the dapp directly request the needed chain ID from the wallet.
What changes
Today
- For a dapp to operate on a different chain, the user must switch chains directly in the wallet
- If the user forgets to switch, the request may be processed on an unintended chain
After EIP-3326
- The dapp requests the desired chain ID from the wallet via wallet_switchEthereumChain
- The wallet may approve or reject the request
- On approval, the active chain changes and null is returned; on rejection or failure, an error is returned
Who is affected
- Users: When switching chains, the user can see a confirmation prompt showing the requester and the target chain, and approve or reject it.
- Wallet developers: Implementers must display a confirmation UI, cancel pending requests and confirmations during a switch, and review the information leakage from automatically rejecting unsupported chains.
- Dapp/app developers: Instead of telling users to manually switch chains, the switch can be requested programmatically.
In depth
Parameters
wallet_switchEthereumChain takes a single object with a chainId field as its parameter. chainId must be in the same format as eth_chainId from EIP-695, representing the chain's integer ID as a hexadecimal string. This chain ID must already be known to the wallet, and the wallet must actually be able to switch to that chain and service RPC requests. If the parameter does not satisfy these requirements, the wallet MUST reject the request.
Return value
If the request succeeds, the method MUST return null. Otherwise it must return an error. This method presumes that the wallet has a single 'active chain' concept, and a wallet without an active-chain concept must reject the request when it receives one.
Security considerations
If the active chain changes without the user being aware, a dapp could induce the user to act on an unintended chain. To prevent this, the wallet must show a confirmation prompt clearly indicating the requester and the chain to switch to every time it receives a request (citing EIP-1102's confirmation prompt as a reference example), and when switching the active chain, it must cancel all pending RPC requests and chain-specific user confirmations.
Privacy considerations
If a wallet automatically rejects requests for chains it does not support or has not yet added, the requester can infer which chains the wallet supports purely from that response pattern. The source states that wallet implementers must review whether this communication channel compromises the wallet's security properties and consider appropriate mitigations if necessary.
Design rationale and related methods
This method is designed to take a single object parameter, a choice made to leave room for future extensibility at virtually no cost to either implementers or users. Related work includes EIP-3085 (wallet_addEthereumChain) and EIP-2015 (wallet_updateEthereumChain), but wallet_switchEthereumChain deliberately focuses solely on changing the active chain, independent of RPC endpoints or other metadata, and does not take on the chain metadata parameters included in those two EIPs.
Current status
This EIP's status is Stagnant. It lists EIP-155 (chain ID based signing) and EIP-695 (eth_chainId) as requires, and no separate fork-inclusion decision is confirmed in the call records.