【问题标题】:I cannot create connector using "@walletconnect/client" and getting error我无法使用“@walletconnect/client”创建连接器并出现错误
【发布时间】:2022-07-06 19:29:02
【问题描述】:

我使用“@walletconnect/client”模块来创建钱包连接器。 这是我的代码:

const WalletConnect = require("@walletconnect/client");
const connector = new WalletConnect({ uri });

这使我的项目出错。

Error: WalletConnect is not a constructor

【问题讨论】:

    标签: javascript node.js reactjs blockchain web3js


    【解决方案1】:

    使用这个 npm 包并安装它,然后使用下面的命令来使用它

    npm i @metamask/detect-provider

    import detectEthereumProvider from '@metamask/detect-provider'
    
    const provider = await detectEthereumProvider()
    
    if (provider) {
    
      console.log('Ethereum successfully detected!')
      })
    } else {
      console.error('Please install MetaMask!', error)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      • 2015-06-15
      相关资源
      最近更新 更多