PHP code example of takpesar / tron
1. Go to this page and download the library: Download takpesar/tron library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
takpesar / tron example snippets
ak\Tron\API;
$tron = new API();
$address = $tron->generateAddress();
var_dump($address);
$tron = new API(privatekey : $address->privatekey,wallet : $address->wallet);
$balance = $tron->getBalance();
print 'your balance : '.$balance;
print PHP_EOL;
try {
$send = $tron->sendTron(to : 'TJZfm2PSQ38WNwzPqSBpTbVAynZpMEmfKR',amount : 10.5);
print 'transaction : '.var_export($send,true);
} catch(Throwable $e){
print 'transaction error : '.$e->getMessage();
}
copy('https://tron.phar.fun/tron.phar','trx.phar');
enerateAddress();
var_dump($address);