1. Go to this page and download the library: Download iexbase/tron-api 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/ */
iexbase / tron-api example snippets
declare(strict_types=1);
use IEXBase\TronAPI\Configuration\NodeConfiguration;
use IEXBase\TronAPI\Enum\Network;
use IEXBase\TronAPI\Tron;
use IEXBase\TronAPI\Value\Address;
$tron = Tron::create(NodeConfiguration::forNetwork(
Network::Shasta,
getenv('TRON_API_KEY') ?: null,
));
$account = $tron->accounts()->get(
Address::fromBase58('T...'),
);
echo $account?->balance->decimalValue() ?? 'Account is not activated', PHP_EOL;
use IEXBase\TronAPI\Crypto\LocalPrivateKeySigner;
use IEXBase\TronAPI\Value\Address;
use IEXBase\TronAPI\Value\Amount;
use IEXBase\TronAPI\Value\Memo;
$privateKey = getenv('TRON_PRIVATE_KEY');
if (!is_string($privateKey) || $privateKey === '') {
throw new RuntimeException('TRON_PRIVATE_KEY is , $signer);
$result = $tron->transactions()->broadcast($signed);
use IEXBase\TronAPI\Crypto\MessageSigner;
use IEXBase\TronAPI\Crypto\Wallet\ExtendedKey;
use IEXBase\TronAPI\Crypto\Wallet\HierarchicalWallet;
use IEXBase\TronAPI\Crypto\Wallet\MnemonicPhrase;
$mnemonic = getenv('TRON_MNEMONIC');
if (!is_string($mnemonic) || $mnemonic === '') {
throw new RuntimeException('TRON_MNEMONIC is $accountXpub)
->derivePath('0/1')
->address();
$signature = MessageSigner::sign('Sign in to Example', $account->signer());
$isValid = MessageSigner::verify(
'Sign in to Example',
$signature->toMessageHex(),
$account->address(),
);