小编Utk*_*pta的帖子

如何使用 web3-react 将 WalletConnect 集成到您的 Dapp 中?

我一直在尝试按照web3-react文档集成WalletConnect

我用于连接器的配置如下:

import { WalletConnectConnector } from '@web3-react/walletconnect-connector';

export const walletconnect = new WalletConnectConnector({
  rpc: { 1: RPC_URLS[1], 4: RPC_URLS[4] },
  infuraId: INFURA_TOKEN,
  bridge: BRIDGE_URL,
  qrcode: true,
  pollingInterval: 15000,
});
Run Code Online (Sandbox Code Playgroud)

另外,软件包的版本如下:

"@web3-react/core": "^6.0.9",
"@web3-react/walletconnect-connector": "^6.2.0",
Run Code Online (Sandbox Code Playgroud)

当我使用以下代码中解释的activate函数时:useWeb3React()

const { connector, activate, active, account } = useWeb3React();
Run Code Online (Sandbox Code Playgroud)
activate(walletconnect, undefined, true)
    .catch((error) => {
        if (error instanceof UnsupportedChainIdError) {
            activate(walletconnect)
        } else {
            console.log('Pending Error Occured')
        }
    })
Run Code Online (Sandbox Code Playgroud)

它能够生成二维码,我也能够成功扫描手机上的 MetaMask 应用程序,并在移动应用程序上显示已成功连接。

不过,在 Web 应用程序的控制台日志上,它显示一条警告:

Warning: …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs ethereum web3-react

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

ethereum ×1

javascript ×1

reactjs ×1

web3-react ×1