tron-php开发包适用于为PHP应用快速接入TRX、TRC20数字资产的支持能力,即支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。
【推荐学习:PHP视频教程】
tron-php Github地址:https://github.com/Fenguoz/tron-php
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();
以上就是PHP调用实现波场交互[支持TRX/TRC20]的详细内容,更多请关注其它相关文章!