transactionBuilder.php 736 B

12345678910111213141516171819
  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. try {
  11. $transaction = $tron->getTransactionBuilder()->sendTrx('to', 2,'fromAddress');
  12. $signedTransaction = $tron->signTransaction($transaction);
  13. $response = $tron->sendRawTransaction($signedTransaction);
  14. } catch (\IEXBase\TronAPI\Exception\TronException $e) {
  15. die($e->getMessage());
  16. }