How to get balanceOf of tron smart contract

I am using tronlink chrome extension and trying to call balanceOf method of a smart contract. I am very new to smart contract. Unable to find any solution. Please check my code:

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 

asked Mar 1, 2021 at 16:52
Haren Sarma Haren Sarma
2,417 6 6 gold badges 45 45 silver badges 74 74 bronze badges

I’m not familiar with tronlink and have no way to check the code, so I’m not going to post it as answer. But it seems like the line should be contract.balanceOf(‘

‘); since balanceOf() is usually a function on Ethereum tokens.

Leave a Reply

Your email address will not be published. Required fields are marked *