【发布时间】:2021-10-02 22:43:54
【问题描述】:
我在 walletconnectprovider 和 web3 中使用 angular 我在调用 web3 没有返回任何响应的合同中的任何方法时遇到了这个问题。
这就是我初始化提供程序的方式
this.provider = new WalletConnectProvider({
// infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
rpc: {
56: "https://bsc-dataseed.binance.org/"
},
chainId: 56
});
初始化 web3 和合约
const web3 = await new Web3(this.provider as any);
const contract = new web3.eth.Contract(JSON.parse(this.smartContract.abi),this.smartContract.contractAddress,{
from: this.provider.wc.accounts[0]
});
每次我调用这个方法时,它下面的所有代码都不会执行。我还检查了我的网络选项卡,似乎根本没有运行 Http 请求。
await contract.methods.balanceOf(this.toAddress).call()
// codes here is not called
【问题讨论】:
-
你有没有解决过这个问题,我也有同样的问题,只是在等待发送或呼叫的承诺时挂起,与 web3 中的其他承诺一起工作正常,例如web3.eth.getAccounts()
-
仅更新 .call 将与 @wallet-connect/ethereum-provider 一起使用,但 .send 不起作用,交易将签署并完成,但承诺不会解决或捕获
-
你们找到解决方案了吗?我也卡在这里了。
标签: angular web3 wallet-connect