contract_balance.php 629 B

123456789101112131415161718
  1. <?php
  2. $fullNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
  3. $solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
  4. $eventServer = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
  5. try {
  6. $tron = new \IEXBase\TronAPI\Tron($fullNode, $solidityNode, $eventServer);
  7. } catch (\IEXBase\TronAPI\Exception\TronException $e) {
  8. exit($e->getMessage());
  9. }
  10. $balance=$tron->getTransactionBuilder()->contractbalance($tron->getAddress);
  11. foreach($balance as $key =>$item)
  12. {
  13. echo $item["name"]. " (".$item["symbol"].") => " . $item["balance"] . "\n";
  14. }