EIP-3085: wallet_addEthereumChain

This topic is for discussing EIP-3085. Discussion was originally located at this GitHub issue on the EIPs repository.

Discussion is expected to pick up again as 3085 moves to Review and then Last Call.

1 Like

A draft PR is up for a related method, wallet_switchEthereumChain: https://github.com/ethereum/EIPs/pull/3326

Instead of decimals, consider requiring a scaling factor instead. This would allow chains that have scaling factors other than base 10 to be supported. Ethereum would be 10^18 but other-chain may be 2^32.

1 Like

Oh, interesting idea. Something like scalingFactor: string matching RegEx /[1-9]\d*\^[1-9]\d*/? Or maybe scalingFactor: [base: number, exponent: number] where the tuple members are positive integers?

Then we could make scalingFactor mutually exclusive with decimals.

Scaling factor can just be a QUANTITY (hex string encoded number). No need for anything fancy here I think.

2 Likes

Ah, naturally. I’ll PR that in the morning :+1:

1 Like

Watch an overview of the proposal with @rekmarks

2 Likes

Hello,

I am facing an issue while calling wallet_addEthereumChain.
I will appreciate it if you can help me to fix this issue.

ethereum.request({
method: ‘wallet_addEthereumChain’,
params: [{
“chainId”: “0x3”,
“chainName”: “Ropsten Network”,
“rpcUrls”: [
https://ropsten.infura.io/v3/4ee71c3a70404cf8b1241df95bbc1347”,
],
“iconUrls”: [
https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0/logo.png
],
“nativeCurrency”: {
“name”: “ETHER Token”,
“symbol”: “ETH”,
“decimals”: 18
}
}]

And this is the issue:
image

Thanks in advance.

1 Like

Actually, I added blockExplorerUrls to the params. Sorry to forgot adding it to the code.
“blockExplorerUrls”: [
https://ropsten.etherscan.io
],

FYI, I confirmed that my Infura Project ID is working. This issue is definitely related to the “rpcUrls”.
When I change it to “https://dai.poa.network” with xDAI Chain, it perfectly worked.

1 Like

I imagine you figured this out by now, but:

wallet_addEthereumChain doesn’t (or at least originally didn’t) support switching to a default network (any Ethereum network like Mainnet, Ropsten, etc.)

Now you can use a combination of wallet_addEthereumChain and wallet_switchEthereumChain in your dapp to add new networks for users if they do not have it in their MM already, and switch back to default chains like Ropsten afterwards.

You can read more here:

I’m finding the wording in this EIP a bit puzzling, particularly around the rpcUrls field’s requirements.

Initially, the document states:

Only the chainId is required per this specification, but a wallet MAY require any other fields listed, impose additional requirements on them, or outright ignore them.

However, later on, it asserts:

The wallet MUST reject the request if the rpcUrls field is not provided, or if the rpcUrls field is an empty array.

Moreover, the parameter interface is described as follows:

interface AddEthereumChainParameter {
  chainId: string;
  blockExplorerUrls?: string[];
  chainName?: string;
  iconUrls?: string[];
  nativeCurrency?: {
    name: string;
    symbol: string;
    decimals: number;
  };
  rpcUrls?: string[];
}

From my understanding, this suggests a wallet “MAY” need the rpcUrls fields, yet it also states a wallet “MUST” reject requests lacking the rpcUrls field. This seems contradictory to me. If this isn’t a contradiction, perhaps the wording needs clarification to explain why this isn’t the case. Could there also be an explanation or scenario where a wallet could function without an rpcUrl , if such a situation is feasible?