PHPackages                             it-healer/laravel-tron - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. it-healer/laravel-tron

ActiveLibrary[API Development](/categories/api)

it-healer/laravel-tron
======================

A library for Laravel that allows you to create and manage the Tron cryptocurrency.

v1.6.2(1w ago)2164MITPHPPHP &gt;=8.1

Since Jul 23Pushed 2w agoCompare

[ Source](https://github.com/it-healer/laravel-tron)[ Packagist](https://packagist.org/packages/it-healer/laravel-tron)[ Docs](https://github.com/it-healer/laravel-tron)[ RSS](/packages/it-healer-laravel-tron/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (16)Versions (18)Used By (0)

[![Logo](docs/logo.jpeg)](docs/logo.jpeg)

Laravel Tron Package
====================

[](#laravel-tron-package)

 [ ![Latest Version](https://camo.githubusercontent.com/ada20120978b4efc6c1f09520442e050566c84f4450323c7bad9ea1930091662/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69742d6865616c65722f6c61726176656c2d74726f6e2e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/it-healer/laravel-tron) [ ![Total Downloads](https://camo.githubusercontent.com/caf664ba7ff004c93caa1bdc906ed634b80ca758b50b6f14b24d515ef40d4b62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69742d6865616c65722f6c61726176656c2d74726f6e2e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/it-healer/laravel-tron) [ ![License](https://camo.githubusercontent.com/234a03793c74510f5782bd4735abf20ca9f851f235ae6100cc7794cbf3109372/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f69742d6865616c65722f6c61726176656c2d74726f6e2e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/it-healer/laravel-tron) [ ![Tests](https://camo.githubusercontent.com/937e105fc83966d970d459cb02a1c3da1ba44f5e9522992176e869fce65b8a52/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265) ](https://github.com/it-healer/laravel-tron/actions)

**Laravel Tron** is a comprehensive Laravel package for working with the Tron blockchain and TRC-20 tokens. It allows you to generate HD wallets using mnemonic phrases (BIP39/BIP44), validate addresses, check balances and resources, preview and send TRX/TRC-20 tokens. Automate cryptocurrency receiving and withdrawals in your Laravel application with ease.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
- [Usage](#usage)
    - [Working with Nodes](#working-with-nodes)
    - [Working with Wallets](#working-with-wallets)
    - [Working with Addresses](#working-with-addresses)
    - [Working with TRX](#working-with-trx)
    - [Working with TRC-20 Tokens](#working-with-trc-20-tokens)
- [Advanced Usage](#advanced-usage)
- [Testing](#testing)
- [Artisan Commands](#artisan-commands)
- [Security](#security)
- [Troubleshooting](#troubleshooting)
- [Changelog](#changelog)
- [Support](#support)
- [Credits](#credits)
- [License](#license)

Features
--------

[](#features)

✨ **Key Features:**

- 🔐 **Built-in BIP39/BIP44 Support** - No external dependencies for mnemonic generation
- 💼 **HD Wallet Generation** - Create hierarchical deterministic wallets
- 🎯 **Multiple Address Support** - Generate unlimited addresses from a single seed
- 💰 **TRX &amp; TRC-20 Support** - Full support for native TRX and TRC-20 tokens
- 🔄 **Automatic Synchronization** - Background sync of transactions and balances
- 📊 **Resource Management** - Track bandwidth and energy usage
- 🎨 **Customizable Models** - Extend default models to fit your needs
- 🔔 **Webhook Handler** - Custom event handling for deposits
- 🧪 **Fully Tested** - Comprehensive test suite with 17 tests
- 🛡️ **Secure** - Encrypted storage for sensitive data

Requirements
------------

[](#requirements)

- **PHP:** 8.1 or newer
- **Laravel:** 10.0 or newer (tested with Laravel 10, 11, and 12)
- **PHP Extensions:**
    - `ext-gmp` - GNU Multiple Precision arithmetic
    - `ext-ctype` - Character type checking
- **External Services:**
    - TronGrid API key ([Get one here](https://www.trongrid.io/register))

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require it-healer/laravel-tron
```

Run the installer command:

```
php artisan tron:install
```

This will publish the configuration file and migrations.

Run the migrations:

```
php artisan migrate
```

### Laravel 11+ (Automatic Discovery)

[](#laravel-11-automatic-discovery)

The package will be automatically discovered. No additional steps needed!

### Laravel 10 (Manual Registration)

[](#laravel-10-manual-registration)

For Laravel 10, register the Service Provider and Facade in `config/app.php`:

```
'providers' => ServiceProvider::defaultProviders()->merge([
    // ...
    \ItHealer\LaravelTron\TronServiceProvider::class,
])->toArray(),

'aliases' => Facade::defaultAliases()->merge([
    // ...
    'Tron' => \ItHealer\LaravelTron\Facades\Tron::class,
])->toArray(),
```

### Scheduler Setup

[](#scheduler-setup)

**For Laravel 10:**

Edit `app/Console/Kernel.php` and add to the `schedule()` method:

```
protected function schedule(Schedule $schedule): void
{
    $schedule->command('tron:sync')
        ->everyMinute()
        ->runInBackground();
}
```

**For Laravel 11+:**

Add to `routes/console.php`:

```
use Illuminate\Support\Facades\Schedule;

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

Configuration
-------------

[](#configuration)

After installation, you'll find the configuration file at `config/tron.php`:

```
return [
    /*
     * Touch Synchronization System (TSS)
     * Optimize sync by only updating recently touched addresses
     */
    'touch' => [
        'enabled' => false,
        'waiting_seconds' => 3600, // 1 hour
    ],

    /*
     * Webhook handler for deposit events
     */
    'webhook_handler' => \ItHealer\LaravelTron\Handlers\EmptyWebhookHandler::class,

    /*
     * Custom model classes
     */
    'models' => [
        'api' => \ItHealer\LaravelTron\Api\Api::class,
        'node' => \ItHealer\LaravelTron\Models\TronNode::class,
        'wallet' => \ItHealer\LaravelTron\Models\TronWallet::class,
        'address' => \ItHealer\LaravelTron\Models\TronAddress::class,
        'trc20' => \ItHealer\LaravelTron\Models\TronTRC20::class,
        'transaction' => \ItHealer\LaravelTron\Models\TronTransaction::class,
        'deposit' => \ItHealer\LaravelTron\Models\TronDeposit::class,
    ]
];
```

### Custom Webhook Handler

[](#custom-webhook-handler)

Create a custom webhook handler to process deposit events:

```
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.
    }
}
```

Then update `config/tron.php`:

```
'webhook_handler' => \App\Handlers\CustomWebhookHandler::class,
```

Quick Start
-----------

[](#quick-start)

### 1. Register with TronGrid

[](#1-register-with-trongrid)

First, create an account on [TronGrid](https://www.trongrid.io/register) and generate an [API key](https://www.trongrid.io/dashboard/keys).

### 2. Create a Tron Node

[](#2-create-a-tron-node)

```
use ItHealer\LaravelTron\Facades\Tron;

$apiKey = "your-trongrid-api-key";
$node = Tron::createTronGridNode($apiKey, 'MainNet Node');
```

### 3. Generate a Wallet

[](#3-generate-a-wallet)

```
// 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);
```

### 4. Create an Address

[](#4-create-an-address)

```
// 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;
```

### 5. Send TRX

[](#5-send-trx)

```
$recipientAddress = 'TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW';
$amount = 10; // 10 TRX

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

echo 'Transaction ID: ' . $transfer->txid;
```

Usage
-----

[](#usage)

### Working with Nodes

[](#working-with-nodes)

#### Create a Node

[](#create-a-node)

```
use ItHealer\LaravelTron\Facades\Tron;

// Using TronGrid
$node = Tron::createTronGridNode($apiKey, 'Node Name');

// Custom node
$node = Tron::createNode('Node Name', 'https://api.trongrid.io');
```

#### Alchemy as RPC node

[](#alchemy-as-rpc-node)

Alchemy can serve Tron **RPC** (balances, account resources, `triggerconstantcontract`, broadcast), but **not** the TronGrid address-history endpoints (`v1/accounts/.../transactions`). `createAlchemyNode()` points RPC at Alchemy and keeps history (and therefore deposit detection) on TronGrid via a separate indexer provider — pass your TronGrid API key for that:

```
$node = Tron::createAlchemyNode(
    apiKey: 'YOUR_ALCHEMY_KEY',
    name: 'alchemy',
    tronGridApiKey: 'YOUR_TRONGRID_KEY', // used only for v1 history; omit to fall back to Alchemy
);
```

Under the hood the node stores an optional `index_node` ({url, headers}); `ApiManager` routes `v1/*` requests to it when set, everything else to the RPC node.

#### Get Node Information

[](#get-node-information)

```
$node = Tron::getNode(); // Get default node
$apiUrl = $node->api_url;
$requestsCount = $node->requests;
```

### Working with Wallets

[](#working-with-wallets)

#### Generate Wallet

[](#generate-wallet)

```
// Generate with default 15 words
$mnemonic = Tron::mnemonicGenerate();

// Generate with custom word count (12, 15, 18, 21, or 24)
$mnemonic = Tron::mnemonicGenerate(24);

// Create wallet
$wallet = Tron::createWallet('Wallet Name', $mnemonic);
```

#### Import Existing Wallet

[](#import-existing-wallet)

```
$mnemonic = "your existing twenty four word mnemonic phrase here...";
$wallet = Tron::importWallet('Imported Wallet', $mnemonic);
```

#### Wallet with Passphrase

[](#wallet-with-passphrase)

```
$mnemonic = Tron::mnemonicGenerate();
$passphrase = "super-secret-passphrase";
$wallet = Tron::createWallet('Wallet Name', $mnemonic, $passphrase);
```

#### Validate Mnemonic

[](#validate-mnemonic)

```
$isValid = Tron::mnemonicValidate($mnemonic);
if ($isValid) {
    echo "Mnemonic is valid!";
}
```

### Working with Addresses

[](#working-with-addresses)

#### Create Address

[](#create-address)

```
// Create with auto-incremented index
$address = Tron::createAddress($wallet, 'Address Label');

// Create with specific index
$address = Tron::newAddress($wallet, 'Custom Address', $index = 5);
```

#### Import Watch-Only Address

[](#import-watch-only-address)

```
$address = Tron::importAddress($wallet, 'TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW');
```

#### Validate Address

[](#validate-address)

```
$isValid = Tron::validateAddress('TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW');
```

#### Get Address Balance

[](#get-address-balance)

```
$balance = $address->balance; // Balance in TRX
$balanceSun = $address->balance_sun; // Balance in SUN (1 TRX = 1,000,000 SUN)
```

#### Get Address Resources

[](#get-address-resources)

```
$resources = $address->getResources();
echo "Bandwidth: " . $resources->bandwidth;
echo "Energy: " . $resources->energy;
```

### Working with TRX

[](#working-with-trx)

#### Preview Transfer

[](#preview-transfer)

```
$preview = Tron::transferPreview($address, $recipientAddress, $amount);

echo "Fee: " . $preview->fee . " TRX";
echo "Total: " . $preview->total . " TRX";
```

#### Send TRX

[](#send-trx)

```
$transfer = Tron::transfer($address, $recipientAddress, $amount);

if ($transfer->success) {
    echo "Transaction sent! TXID: " . $transfer->txid;
} else {
    echo "Transfer failed: " . $transfer->error;
}
```

### Working with TRC-20 Tokens

[](#working-with-trc-20-tokens)

#### Register TRC-20 Token

[](#register-trc-20-token)

```
use ItHealer\LaravelTron\Models\TronTRC20;

// USDT TRC-20 contract address
$contractAddress = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';

$token = TronTRC20::create([
    'contract_address' => $contractAddress,
    'name' => 'Tether USD',
    'symbol' => 'USDT',
    'decimals' => 6,
]);
```

#### Get TRC-20 Balance

[](#get-trc-20-balance)

```
$balance = $address->getTRC20Balance($token);
echo "USDT Balance: " . $balance;
```

#### Preview TRC-20 Transfer

[](#preview-trc-20-transfer)

```
$preview = Tron::transferTRC20Preview($address, $recipientAddress, $amount, $token);

echo "Fee: " . $preview->fee . " TRX";
echo "Energy Required: " . $preview->energy_required;
```

#### Send TRC-20 Tokens

[](#send-trc-20-tokens)

```
$transfer = Tron::transferTRC20($address, $recipientAddress, $amount, $token);

if ($transfer->success) {
    echo "Transaction sent! TXID: " . $transfer->txid;
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Models

[](#custom-models)

Extend the default models to add custom functionality:

```
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);
    }
}
```

Update `config/tron.php`:

```
'models' => [
    'wallet' => \App\Models\TronWallet::class,
    // ...
],
```

### Touch Synchronization System (TSS) — adaptive sync

[](#touch-synchronization-system-tss--adaptive-sync)

For applications with many addresses, enable TSS so addresses are polled **often while in use and rarely while idle**, instead of every run. An address is "active" for `waiting_seconds`after its last `touch_at`; while active it syncs no more often than `fast_interval`, while idle no more often than `slow_interval`.

```
// 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)
],
```

Mark activity by updating `touch_at` when the wallet is used (GUI view, API call, unlock):

```
$address->update(['touch_at' => now()]);
// or in bulk for a wallet:
$wallet->addresses()->update(['touch_at' => now()]);
```

Defaults (`fast_interval` 0, `slow_interval` null) preserve the legacy behavior: active addresses sync every run, idle ones are skipped. `tron:address-sync --force` bypasses the schedule.

### Multiple Derivation Paths

[](#multiple-derivation-paths)

The package uses BIP44 standard with the path `m/44'/195'/0'/0` for Tron:

```
// 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);
```

Testing
-------

[](#testing)

The package includes a comprehensive test suite:

```
# Run all tests
composer test

# Run with detailed output
vendor/bin/phpunit --testdox

# Run specific test
vendor/bin/phpunit --filter MnemonicTest
```

**Test Coverage:**

- ✅ BIP39 mnemonic generation (12, 15, 24 words)
- ✅ BIP39 mnemonic validation
- ✅ Seed generation with/without passphrase
- ✅ BIP44 address derivation
- ✅ Private/public key generation
- ✅ Address generation from private keys
- ✅ Multiple address generation

See [tests/README.md](tests/README.md) for more details.

Artisan Commands
----------------

[](#artisan-commands)

### Synchronization Commands

[](#synchronization-commands)

```
# Sync everything (all nodes, wallets, addresses)
php artisan tron:sync

# Sync specific node
php artisan tron:sync-node {nodeId}

# Sync specific wallet
php artisan tron:sync-wallet {walletId}

# Sync specific address
php artisan tron:sync-address {addressId}
```

### Creation Commands

[](#creation-commands)

```
# Create a new Tron node
php artisan tron:new-node

# Create a new wallet
php artisan tron:new-wallet

# Generate a new address
php artisan tron:new-address

# Import watch-only address
php artisan tron:import-address

# Register TRC-20 token
php artisan tron:new-trc20
```

Security
--------

[](#security)

### Best Practices

[](#best-practices)

- 🔐 **Never store mnemonics in plain text** - Always encrypt sensitive data
- 🔑 **Use strong passphrases** - Add an additional layer of security to wallets
- 🌐 **Use HTTPS** - Always communicate with Tron nodes over HTTPS
- 🔒 **Secure your database** - Encrypt database backups and use strong credentials
- 👥 **Limit access** - Restrict who can access wallet operations
- 📝 **Log transactions** - Keep audit logs of all cryptocurrency operations
- 🧪 **Test on testnet first** - Always test on Shasta testnet before mainnet

### Encrypted Storage

[](#encrypted-storage)

The package automatically encrypts sensitive data:

- Private keys are encrypted using Laravel's encryption
- Mnemonics are encrypted before storage
- Passwords are hashed using bcrypt

### Reporting Vulnerabilities

[](#reporting-vulnerabilities)

If you discover a security vulnerability, please email . All security vulnerabilities will be promptly addressed.

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

**Issue: "Class 'GMP' not found"**

```
# Install GMP extension
# Ubuntu/Debian
sudo apt-get install php-gmp

# macOS (Homebrew)
brew install gmp
```

**Issue: "Invalid mnemonic phrase"**

- Ensure the mnemonic has the correct number of words (12, 15, 18, 21, or 24)
- Check for typos in the mnemonic words
- Verify words are from the BIP39 wordlist

**Issue: "Insufficient energy"**

- Freeze TRX to get energy
- Or use TRX to pay for energy (higher cost)
- Consider using `transferPreview()` to estimate costs

**Issue: "Node API limit exceeded"**

- TronGrid free tier has rate limits
- Upgrade to a paid plan on TronGrid
- Or use your own Tron node

### Debug Mode

[](#debug-mode)

Enable debug logging in `.env`:

```
LOG_LEVEL=debug
```

Check logs in `storage/logs/laravel.log` for detailed information.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Support
-------

[](#support)

Need help? Reach out to us:

- 💬 **Telegram:** [@biodynamist](https://t.me/biodynamist)
- 📱 **WhatsApp:** [+905516294716](https://wa.me/905516294716)
- 🌐 **Website:** [it-healer.com](https://it-healer.com)
- 📧 **Email:**
- 🐛 **Issues:** [GitHub Issues](https://github.com/it-healer/laravel-tron/issues)

Credits
-------

[](#credits)

- [IT-HEALER](https://github.com/it-healer)
- Built with ❤️ using [Laravel](https://laravel.com)
- Powered by [TronGrid](https://www.trongrid.io)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

---

 Made with ❤️ by [IT-HEALER](https://it-healer.com)

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance97

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~0 days

Total

17

Last Release

11d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/222434019?v=4)[IT-HEALER | Путь от Программиста к Целителю](/maintainers/it-healer)[@it-healer](https://github.com/it-healer)

---

Top Contributors

[![it-healer](https://avatars.githubusercontent.com/u/222434019?v=4)](https://github.com/it-healer "it-healer (11 commits)")

---

Tags

apiblockchaincryptocurrencylaravellibraryphptokenstrc-20trontrxphplaraveltronit-healer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/it-healer-laravel-tron/health.svg)

```
[![Health](https://phpackages.com/badges/it-healer-laravel-tron/health.svg)](https://phpackages.com/packages/it-healer-laravel-tron)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M101](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[lettermint/lettermint-laravel

Official Lettermint driver for Laravel

1190.2k1](/packages/lettermint-lettermint-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
