PHP code example of sultanov-solutions / tron-api

1. Go to this page and download the library: Download sultanov-solutions/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/ */

    

sultanov-solutions / tron-api example snippets


use IEXBase\TronAPI\Tron;

// Defaults to mainnet
$tron = Tron::init();

// Or with options / network preset
$tron = Tron::init([
    'network' => 'shasta',
    // 'api_key' => 'YOUR_TRONGRID_KEY',
    // 'endpoints' => ['full_node' => 'https://...', 'solidity_node' => 'https://...']
]);

$tron->setAddress('TYourAddressBase58OrHex');
$balance = $tron->getBalance(null, true);

use IEXBase\TronAPI\Laravel\Facades\Tron; // or app('tron')

// Fresh instance for default connection from config
$tron = Tron::make();

// Or choose connection + override options for this instance
$tron = Tron::make('shasta', ['timeout_ms' => 20000, 'api_key' => 'TEST_KEY']);

$balance = $tron->getBalance(null, true);

$tron = \IEXBase\TronAPI\Laravel\Facades\Tron::make('mainnet', ['api_key' => 'OVERRIDE_KEY']);
bash
php artisan vendor:publish --tag=tron-connection-config