TRON-PHP 目前支持波场的 TRX 和 TRC20 中常用生成地址,发起转账,离线签名等功能。
generateAddress()
validateAddress(Address $address)
privateKeyToAddress(string $privateKeyHex)
balance(Address $address)
transfer(Address $from, Address $to, float $amount)
blockNumber()
blockByNumber(int $blockID)
transactionReceipt(string $txHash)
composer require fenguoz/tron-php
use GuzzleHttp\Client;
$uri = 'https://api.shasta.trongrid.io';// shasta testnet
$api = new \Tron\Api(new Client(['base_uri' => $uri]));
$trxWallet = new \Tron\TRX($api);
$addressData = $trxWallet->generateAddress();
// $addressData->privateKey
// $addressData->address
$config = [
'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20
'decimals' => 6,
];
$trc20Wallet = new \Tron\TRC20($api, $this->config);
$addressData = $trc20Wallet->generateAddress();
扩展包名 | 描述 | 应用场景 |
---|---|---|
iexbase/tron-api | 波场官方文档推荐 PHP 扩展包 | 波场基础Api |