metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

Can't add Optimism network on MetaMask mobile

Open ranmocy opened this issue 3 years ago • 2 comments

Describe the bug Calling wallet_addEthereumChain to add Optimism network on MetaMask mobile will throw exception with message: May not specify default MetaMask chain.

To Reproduce

Send request from a dApp running within MetaMask mobile browser:

window.ethereum.request({
  method: 'wallet_addEthereumChain',
  params: [
    {
      chainId: "0xa",
      chainName: "Optimism",
      rpcUrls: ["https://mainnet.optimism.io"],
      blockExplorerUrls: ["https://optimistic.etherscan.io"],
      nativeCurrency: {
        "name": "ETH",
        "symbol": "ETH",
        "decimals": 18
      }
    }
  ]
})

Expected behavior

Optimism is added successfully as a custom network.

Smartphone (please complete the following information):

  • Device: Pixel 5a
  • OS: Android 12
  • App Version: 5.2.0

to be added after bug submission by internal support / PM Severity

  • How critical is the impact of this bug on a user?
  • Add stats if available on % of customers impacted
  • Is this visible to all users?
  • Is this tech debt?

ranmocy avatar Jun 14 '22 00:06 ranmocy

From what I can see, the exception is thrown from this line in wallet_addEthereumChain.js, where it checks the chainId against this list NetworksChainId.

The list contains optimism network, therefore it rejects the request.

I think the condition is incorrect, it should checks if the network has been added to the local network lists, instead of NetworksChainId. The list contains networks that are not really added as default networks (which is optimism and optimismTest.

ranmocy avatar Jun 14 '22 01:06 ranmocy

Having the same problem with my web3 app on MetaMask Mobile. Also noticed that bug with other web3 apps such as 1inch. Can you please fix this?

tempe-techie avatar Jul 18 '22 12:07 tempe-techie

still can not use mobile app for Calling wallet_addEthereumChain to add Optimism chain

ios app v5.12.3

same issue for May not specify default MetaMask chain.

Describe the bug Calling wallet_addEthereumChain to add Optimism network on MetaMask mobile will throw exception with message: May not specify default MetaMask chain.

To Reproduce

Send request from a dApp running within MetaMask mobile browser:

window.ethereum.request({
  method: 'wallet_addEthereumChain',
  params: [
    {
      chainId: "0xa",
      chainName: "Optimism",
      rpcUrls: ["https://mainnet.optimism.io"],
      blockExplorerUrls: ["https://optimistic.etherscan.io"],
      nativeCurrency: {
        "name": "ETH",
        "symbol": "ETH",
        "decimals": 18
      }
    }
  ]
})

Expected behavior

Optimism is added successfully as a custom network.

Smartphone (please complete the following information):

  • Device: Pixel 5a
  • OS: Android 12
  • App Version: 5.2.0

to be added after bug submission by internal support / PM Severity

  • How critical is the impact of this bug on a user?
  • Add stats if available on % of customers impacted
  • Is this visible to all users?
  • Is this tech debt?

yichunsung avatar Jan 09 '23 19:01 yichunsung