Metamask: wallet_addEthereumChain is not working in metamask android app
Metamask Wallet Add Ethereum Chain Error: Wrong Chain ID
As a development, In this article,
The problem
When using the Wallet_addethereumchain RPC Function in a metamask Android app The chainid property of the Ethereum network object returned by this function is crucial for proper identification and management of custom networks.
The Error
. Specifically, it says “wrong chain ID”. This suggests that there might be an issue with how you
Code Review

Let’s Take a Closer Look at Your Code Snippet:
`JavaScript
Const Chain = Await Provider.getchain (“Customnetwork”);
Const chainid = chain.chainid;
Wallet_addethereumchain ({
Network: Chain,
from: Accountaddarress,
});
`
Notice that we are passing the chainid as an argument to thewallet_addethereumchain function. However, in your code, you are only pass the Custom Network Object Directly:
`JavaScript
Const Chain = Await Provider.getchain (“Customnetwork”);
Wallet_addethereumchain ({
from: Accountaddarress,
});
`
As we are passing the custom network to the wallet, This is likely causing the issue with the wrong chain id.
Solution
Chainid Value when calling Wallet_addethereumchain. Here’s an updated code snippet:
`JavaScript
Const Chain = Await Provider.getchain (“Customnetwork”);
Const chainid = chain.chainid;
Wallet_addethereumchain ({
Network: Chain,
from: Accountaddarress,
});
`
Additional Advice
Ethereum Networks, make sure to:
1.
.
3.
The wrong chain ID issue and successfully integrate your custom Ethereum Network into your Android application using metamask.

Leave a Reply
Want to join the discussion?Feel free to contribute!