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