web3wallet.on 不是函数

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

使用 WalletConnect 我想连接我的 dApp 和用户的加密钱包。在代码中code image我已经在react App功能组件中导入了所有必要的包和方法,在执行该功能时抛出错误“web3wallet.on is not a function”。 Error immage。建议任何解决方案来克服这个错误?

 web3wallet.on("session_proposal", async (proposal) => {
console.log("proposal", proposal)
const session = await web3wallet.approveSession({
  id: proposal.id,
  namespaces: {
    "requiredNamespaces": {
      "eip155": {
        "chains": ["eip155:1", "eip155:137"],
        "methods": ["eth_sendTransaction", "eth_signTransaction", "eth_sign", "get_balance"],
        "events": ["accountsChanged", "chainChanged"]
      },
      "eip155:10": {
        "methods": ["get_balance"],
        "events": ["accountsChanged", "chainChanged"]
      },
      "cosmos": {}
    },
    "optionalNamespaces": {
      "eip155:42161": {
        "methods": ["eth_sendTransaction", "eth_signTransaction", "get_balance", "personal_sign"],
        "events": ["accountsChanged", "chainChanged"]
      }
    }
  },
});
console.log("session", session)

});

wallet-connect web3 web3modal
© www.soinside.com 2019 - 2024. All rights reserved.