tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
423 stars 271 forks source link

get USDT balance of an address #415

Closed m0x61h0x64i closed 1 year ago

m0x61h0x64i commented 1 year ago

Hi, i tried this code to get the USDT balance of an address:

const contractAddress = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'
const { abi } = await tronWeb.trx.getContract(contractAddress)
let contract = await tronWeb.contract(abi.entrys, contractAddress)
const balance = await contract.methods.balanceOf('THpjKwQAPEGHG715fLB49NbH8ZvPtGs7Z6').call()
console.log(balance)

but it shows error:

node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^
class java.security.InvalidParameterException : owner_address isn't set.
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v18.17.0

whats the problem? @summertanh

start940315 commented 1 year ago

It seems like you called a javatron service without providing an owner_address. Maybe the error was note thrown from here?

m0x61h0x64i commented 1 year ago

@start940315 yes, thats correct, thanks for your help