简体   繁体   English

"如何连接到 Coinbase 钱包的 Metamask?"

[英]How to connect to either Metamask for Coinbase wallet?

How do you specify connection with Coinbase Wallet and Metamask separately?如何分别指定与 Coinbase Wallet 和 Metamask 的连接?

Right now when using window.ethereum.enable() both the Metamask and Coinbase Wallet extensions popup.现在,当使用 window.ethereum.enable() 时,Metamask 和 Coinbase 钱包扩展弹出窗口。 I would like two separate buttons, one for Metamask and the other for Coinbase Wallet.我想要两个单独的按钮,一个用于 Metamask,另一个用于 Coinbase 钱包。

My code:我的代码:

const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
const web3 = createAlchemyWeb3(alchemyKey);

export const connectWallet = async () => {
    if (window.ethereum) { //check if Metamask is installed 
      try {
            const address = await window.ethereum.enable(); //connect Metamask
      }
   }
})

From this discussion<\/a> , it seems like you may be able to use a different Metamask request method to force connection selection:这个讨论中<\/a>,您似乎可以使用不同的 Metamask 请求方法来强制连接选择:

  const connectWallet = async () => {
    if (window.ethereum) { //check if Metamask is installed 
      try {
        const address = await window.ethereum.request({
          method: 'wallet_requestPermissions',
          params: [{ eth_accounts: {}}]
        }); 
      } catch (error) {
        console.log(error);
      }
    }
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每当我单击连接元掩码按钮时,为什么它会连接 coinbase 钱包? - Whenever i click on connect metamask button why it connects the coinbase wallet? 如何连接信任钱包和元掩码以与 ethers.js 做出反应 - how to connect trust wallet and metamask in react with ethers.js 如何在 React 上的 bsc 测试网上将 Metamask 钱包地址连接到 web3 - How to connect Metamask wallet address to web3 on bsc testnet on React 尝试将 MetaMask 钱包连接到 React - 如果用户单击 MetaMask 模态,该模态不会重新出现 - When attempting to connect MetaMask wallet to React - if user clicks out of the MetaMask modal, the modal doesn't reappear 如何在 React 的元掩码钱包中获取 BNB 代币余额? - How to get BNB token balance in metamask wallet in React? 如何修复反应应用程序和coinbase连接api上的cors错误 - how fix cors error on react app and coinbase connect api 如何在移动 chrome 浏览器中将 Phantom 钱包连接到 React App? - How to connect Phantom wallet to React App in mobile chrome browser? "如何通过单击 webapp 上的按钮(如 opensea)来检测、启动和连接到 metamask 移动应用程序?" - How to detect,launch and connect to metamask mobile app by clicking on a button on the webapp like on opensea? 如何在不使用元掩码或雾的情况下将本地私有 geth 节点连接到 web 页面? - How to connect local private geth nodes to the web page without using metamask or mist? 使用 http 地址向 MetaMask 添加自定义网络无法使用 wallet_addEthereumChain - Adding a custom network to MetaMask with http address isn't working using wallet_addEthereumChain
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM