首页 > 解决方案 > 使用 Web3js 检索合同信息

问题描述

我无法使用 Web3JS 从智能合约中检索合约余额。我也没有收到错误。

除了 balanceOf 之外,我还尝试调用其他几个函数,它们都返回以下内容:

[符号(kWeak)]:弱引用 {}。

这是我正在使用的代码:

contract.methods.balanceOf(address).call((err, result) => {console.log(result)})
Promise {
  <pending>,
  domain:
   Domain {
     domain: null,
     _events:
      [Object: null prototype] {
        removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [],
     [Symbol(kWeak)]: WeakReference {} } }

预期结果应该是给定地址的账户余额。

标签: ethereumsmartcontractsweb3js

解决方案


推荐阅读