I think this is a fine proposal, with some definite benefit, but I think it leaves some user experience to be desired.
Part of the reason this EIP is needed is because currently the EIP-3085 wallet_addEthereumChain
method will throw an error when trying to switch the user to a “default” network on MetaMask, and so there is currently no programmatic way to suggest a user switch to a “default” network.
One proposed approach is this EIP as well as a hasEthereumChain
method, which combined would mean potentially multiple acts of consent to perform this one action:
- Permission to view available networks
- (if the network is not available) Permission to add & switch to network
- (if the network is available) Permission to switch network
Meanwhile, the dapp didn’t need to view all networks to complete its intended goal of suggesting a network if it wasn’t present. It could’ve provided that fallback case in its original request.
I think these many actions can be summarized with a single method instead, like a switchWithOptionalFallbackToAdd
method. The current proposal could be simply extended with an optional parameter to make this possible.
For example, we could provide an optional parameter fallbackRpc
, which if the user lacked the requested network would fall back to triggering the EIP-3085: wallet_addEthereumChain
logic.
{
"id": 1,
"jsonrpc": "2.0",
"method": "wallet_switchEthereumChain",
"params": [
{
"chainId": "0x5",
"fallbackRpc": {
"chainId": "0x5",
"chainName": "Goerli",
"rpcUrl": "https://goerli.infura.io/v3/INSERT_API_KEY_HERE",
"nativeCurrency": {
"name": "Goerli ETH",
"symbol": "gorETH",
"decimals": 18
},
"blockExplorerUrl": "https://goerli.etherscan.io"
}
}
]
}