uniapp调用web3查询方法及合约交互报错TypeError: Cannot read property 'node' of undefined。h5可以安卓不行

uniapp调用web3查询方法及合约交互报错TypeError: Cannot read property 'node' of undefined。h5可以安卓不行 测试代码 `async linkContract(type){

    let aa = new this.web3.eth.Contract(usdt, '0xB1E169b052c7a2b6fc899Ea7e21365d5b838B98e');
     try {

        const [balance, decimals] = await Promise.all([
          aa.methods.balanceOf("0x44360800Ca20EC6371344A9994526585079523e8").call({form:"0x44360800Ca20EC6371344A9994526585079523e8"}),
          aa.methods.decimals().call()
        ]);

        console.log(`USDT余额: ${balance / (10 ** decimals)}`);
      } catch (error) {
        console.error('查询失败:', error);
      }
}`

    尝试过的解决方法

onlaunch中设置 process.versions={node:"11.2.0"} 设置完成之后报错就变成了 Error: CONNECTION ERROR: Couldn't connect to node https://sepolia.infura.io/v3/api-key 同样无法调用方法

我的web3版本是1.3.4

请先 登录 后评论

1 个回答

哀败
请先 登录 后评论
  • 1 关注
  • 0 收藏,448 浏览
  • 哀败 提出于 2025-08-01 18:26