1. Go to this page and download the library: Download it-healer/laravel-tron 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/ */
namespace App\Handlers;
use ItHealer\LaravelTron\Handlers\WebhookHandler;
use ItHealer\LaravelTron\Models\TronDeposit;
class CustomWebhookHandler extends WebhookHandler
{
public function handle(TronDeposit $deposit): void
{
// Your custom logic here
// Send notification, update user balance, etc.
}
}
use ItHealer\LaravelTron\Facades\Tron;
$apiKey = "your-trongrid-api-key";
$node = Tron::createTronGridNode($apiKey, 'MainNet Node');
// Generate a new mnemonic phrase (15 words by default)
$mnemonic = Tron::mnemonicGenerate(15);
echo 'Mnemonic: ' . implode(' ', $mnemonic);
// Create wallet from mnemonic
$wallet = Tron::createWallet('My Wallet', $mnemonic);
// Primary address is created automatically when wallet is created
// Get the primary address
$address = $wallet->addresses()->first();
// Or create additional addresses
$secondaryAddress = Tron::createAddress($wallet, 'Secondary Address');
echo 'Address: ' . $address->address;
use ItHealer\LaravelTron\Facades\Tron;
// Using TronGrid
$node = Tron::createTronGridNode($apiKey, 'Node Name');
// Custom node
$node = Tron::createNode('Node Name', 'https://api.trongrid.io');
$node = Tron::createAlchemyNode(
apiKey: 'YOUR_ALCHEMY_KEY',
name: 'alchemy',
tronGridApiKey: 'YOUR_TRONGRID_KEY', // used only for v1 history; omit to fall back to Alchemy
);
$isValid = Tron::mnemonicValidate($mnemonic);
if ($isValid) {
echo "Mnemonic is valid!";
}
// Create with auto-incremented index
$address = Tron::createAddress($wallet, 'Address Label');
// Create with specific index
$address = Tron::newAddress($wallet, 'Custom Address', $index = 5);
namespace App\Models;
use ItHealer\LaravelTron\Models\TronWallet as BaseTronWallet;
class TronWallet extends BaseTronWallet
{
// Add custom methods or properties
public function user()
{
return $this->belongsTo(User::class);
}
}
// In config/tron.php
'touch' => [
'enabled' => true,
'waiting_seconds' => 1800, // stay "active" 30 min after last touch
'fast_interval' => 60, // while active: at most once per 60s
'slow_interval' => 3600, // while idle: at most once per hour (null = skip idle entirely)
],
$address->update(['touch_at' => now()]);
// or in bulk for a wallet:
$wallet->addresses()->update(['touch_at' => now()]);
// Create addresses with different indexes from the same wallet
$address0 = Tron::createAddress($wallet, 'Address 0', 0);
$address1 = Tron::createAddress($wallet, 'Address 1', 1);
$address2 = Tron::createAddress($wallet, 'Address 2', 2);