如何获取波场智能合约的balanceOf
How to get balanceOf of tron smart contract
我正在使用 tronlink chrome 扩展并尝试调用智能合约的 balanceOf 方法。我对智能合约很陌生。无法找到任何解决方案。请检查我的代码:
let contractDetail = await window.tronWeb.trx.getContract('TG7DLMkJPYeG4QTZ8Qfgk9Mu7ePM5SQpbN');
let contract = await window.tronWeb.contract(contractDetail.abi.entrys, 'TG7DLMkJPYeG4QTZ8Qfgk9Mu7ePM5SQpbN');
balance = contract.balanceOf.call('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS');
console.log(balance)
//Error: Uncaught TypeError: Cannot read property 'call' of undefined
balanceOf 需要一个参数。
'balanceOf(address)'
而不是
contract.balanceOf.call('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS');
你应该把地址传入balanceOf
contract.balanceOf('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS').call();
使用tronWeb.trx.getBalance(CONTRACT_ADDRESS);
您的代码应该如下所示
balance = await tronWeb.trx.getBalance('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS');
我正在使用 tronlink chrome 扩展并尝试调用智能合约的 balanceOf 方法。我对智能合约很陌生。无法找到任何解决方案。请检查我的代码:
let contractDetail = await window.tronWeb.trx.getContract('TG7DLMkJPYeG4QTZ8Qfgk9Mu7ePM5SQpbN');
let contract = await window.tronWeb.contract(contractDetail.abi.entrys, 'TG7DLMkJPYeG4QTZ8Qfgk9Mu7ePM5SQpbN');
balance = contract.balanceOf.call('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS');
console.log(balance)
//Error: Uncaught TypeError: Cannot read property 'call' of undefined
balanceOf 需要一个参数。
'balanceOf(address)'
而不是
contract.balanceOf.call('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS');
你应该把地址传入balanceOf
contract.balanceOf('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS').call();
使用tronWeb.trx.getBalance(CONTRACT_ADDRESS);
您的代码应该如下所示
balance = await tronWeb.trx.getBalance('TNkJRejobNuZhV2LiwfGQ7wPNiLtcbDueS');