I am trying to call this function which will trigger metamask to change the chain to rinkeby test net but it's not working, It is working for other chains like polygon mainnet and binance mainnet but for Rinkeby it not doing anything

await window.ethereum.request({
    method: 'wallet_switchEthereumChain',
    params: [{
       chainId: `0x${Number(4).toString(16)}`,
       chainName: "Rinkeby",
       nativeCurrency: {
          name: "Rinkeby Ether",
          symbol: "RIN",
          decimals: 18
       rpcUrls: ["https://rinkeby.infura.io/v3/"],
       blockExplorerUrls: ["https://rinkeby.etherscan.io"]

1 Answer 1


I think you mixed up the functions for "switching" and for "adding" a network. The function to switch network should only have to pass the chainId.

This is what my code looks like:

let web3 = window.ethereum;

await web3
    method: "wallet_switchEthereumChain",
    params: [{ chainId: chainId }],
  .catch(() => {});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.