PHP code example of mollsoft / laravel-tron-module

1. Go to this page and download the library: Download mollsoft/laravel-tron-module 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/ */

    

mollsoft / laravel-tron-module example snippets


'providers' => ServiceProvider::defaultProviders()->merge([
    ...,
    \Mollsoft\LaravelTronModule\TronServiceProvider::class,
])->toArray(),

'aliases' => Facade::defaultAliases()->merge([
    ...,
    'Tron' => \Mollsoft\LaravelTronModule\Facades\Tron::class,
])->toArray(),

$schedule->command('tron:sync')
    ->everyMinute()
    ->runInBackground();

use Illuminate\Support\Facades\Schedule;

Schedule::command('tron:sync')
    ->everyMinute()
    ->runInBackground();

$apiKey = "..."; // API Key from TronGrid.io
Tron::createTronGridNode($apiKey, 'node_name');

$mnemonic = Tron::mnemonicGenerate();
echo 'Mnemonic: '.implode(' ', $mnemonic);

$wallet = Tron::createWallet('wallet_name', $mnemonic);

$address = Tron::createAddress($wallet, 'primary_address_name');

echo 'Primary Address: '.$address->address;

$to = 'receiver tron address';
$amount = 1;

$transfer = Tron::transfer($address, $to, $amount);

echo 'TXID: '.$transfer->txid;

$contractAddress = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';

$trc20Token = TronTRC20::create($contractAddress);

$to = 'receiver tron address';
$amount = 1;

$transferTRC20 = Tron::transferTRC20($address, $to, $amount);

echo 'TXID: '.$transferTRC20->txid;
bash
php artisan tron:install
bash
php artisan migrate
bash
php artisan tron:sync
bash
php artisan tron:sync-node NODE_ID
bash
php artisan tron:sync-wallet WALLET_ID
bash
php artisan tron:sync-address ADDRESS_ID
bash
php artisan tron:new-node
bash
php artisan tron:new-wallet
bash
php artisan tron:new-address
bash
php artisan tron:new-trc20