不支持请求方法wallet_switchEthereumChain

问题描述 投票:0回答:1

引发错误的代码片段:

   const { ethereum }: any = window;
   await ethereum.request({
      method: 'wallet_switchEthereumChain',
      params: [{ chainId }],
   });

尝试使用 ethers.js v6:

  const ETHERSJS_PROVIDER = new BrowserProvider(ethereum);
  await ETHERSJS_PROVIDER.send('wallet_switchEthereumChain', [
      { chainId },
  ]);
ethereum web3js metamask ethers.js
1个回答
0
投票

当我安装了 Coinbase 扩展时,我发现了同样的错误。 Coinbase 扩展似乎有错误。

© www.soinside.com 2019 - 2024. All rights reserved.