Tak-Pesar/Tron

demand

sixgodfan opened this issue · 9 comments

Account multi-signature, account permission modification: how to put an account completely managed by another account, request to write a demo, thanks (machine translation)

Fatal error: Uncaught TypeError: Tak\Tron\API::getAccount(): Return value must be of type object, string returned in H:\phpEnv\www\localhost\vendor\takpesar\tron\src\API.php:235 Stack trace: #0 H:\phpEnv\www\localhost\vendor\takpesar\tron\src\API.php(256): Tak\Tron\API->getAccount('415e457c466ac62...') #1 H:\phpEnv\www\localhost\a.php(14): Tak\Tron\API->getBalance() #2 {main} thrown in H:\phpEnv\www\localhost\vendor\takpesar\tron\src\API.php on line 235

When does this happen ?

When getting the balance

<?php
require_once "./vendor/autoload.php";
use Tak\Tron\API;

$tron = new API();
$tron->setWallet('TJZfm2PSQ38WNwzPqSBpTbVAynZpMEmfKR');
$balance = $tron->getBalance();
print 'your balance  : '.$balance;

### Then it reported an error, did I write it incorrectly?

Well, your problem is connecting and sending a request to TronAPI
And I made it not return the error as a string and it throw that error and you can catch it
Just try this :

$tron = new API();
$tron->setWallet('TJZfm2PSQ38WNwzPqSBpTbVAynZpMEmfKR');
try {
    $balance = $tron->getBalance();
    print 'your balance  : '.$balance;
} catch(\Throwable $error){
    print $error->getMessage();
}

Latest version and use your code above to get alerts on balance:
Tak\Tron\API::getAccount(): Return value must be of type object, string returned

Now it gives another error install the latest version please

commit : fb21bf8

Thanks, it is already working fine to get the trx balance. How to get the balance of usdt (TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t) please, write an example, thanks!

You have to calculate yourself based on the price of Tron cryptocurrency. Unfortunately, this does not apply to our library