PHP code example of jinfakeji168 / tron-php
1. Go to this page and download the library: Download jinfakeji168/tron-php 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/ */
jinfakeji168 / tron-php example snippets
$tronSecret = "0000000";//波场私钥
$tronAddress = "Txxxxxx";//波场公钥(波场地址)
//转换成Address类
$fromAddr = $trxWallet->privateKeyToAddress($tronSecret);//发起地址
$toAddr = new Address(
$tronAddress,
'',
$trxWallet->tron->address2HexString($tronAddress)
);//接受地址
$trx = $trxWallet->balance($fromAddr);//获取trx余额
$transferData = $trxWallet->transfer($fromAddr,$toAddr,1); //转账1trx
//以下全部为质押2.0接口
$trxWallet->delegate($fromAddr,$toAddr,1);//代理1trx产生的能量
$trxWallet->undelegate($fromAddr,$toAddr,1);//收回1trx产生的能量
$trxWallet->delegate($fromAddr,$toAddr,1,"BANDWITH");//代理1trx产生的带宽
$trxWallet->undelegate($fromAddr,$toAddr,"BANDWITH");//收回1trx产生的带宽
$trxWallet->delegate($fromAddr,$toAddr,1,"ENERGY",true,1200);//代理1trx产生的能量,锁定期1小时,单位为3秒
$trxWallet->tron->getdelegatedresourceaccountindexv2($fromAddr->address);//获取全部已经代理的资源
$trxWallet->getFrozenEnergyPrice($toAddr);//质押1trx获得的能量 例如12.369
$trxWallet->getNetEnergyPrice($toAddr);//质押1trx获得的带宽 例如1.197
php
composer
php
//usdt转账
$tronSecret = "0000000";//波场私钥
$tronAddress = "Txxxxxx";//波场公钥(波场地址)
//转换成Address类
$fromAddr = $trc20Wallet->privateKeyToAddress($tronSecret);//发起地址
$toAddr = new Address(
$tronAddress,
'',
$trc20Wallet->tron->address2HexString($tronAddress)
);//接受地址
$usdt = $trc20Wallet->balance($fromAddr);//获取usdt余额
$transferData = $trc20Wallet->transfer($fromAddr,$toAddr,1);//转账1usdt