sakoora0x/laravel-tron-module

Laravel Tron Module

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 6

pkg:composer/sakoora0x/laravel-tron-module

dev-main 2025-10-24 04:08 UTC

This package is not auto-updated.

Last update: 2025-10-25 01:36:07 UTC


README

Pest Laravel Expectations

Latest Version on Packagist Php Version Php Version Total Downloads

Website Telegram

Laravel Tron Module is a Laravel package for work with cryptocurrency Tron, with the support TRC-20 tokens.It allows you to generate HD wallets using mnemonic phrase, validate addresses, get addresses balances and resources, preview and send TRX/TRC-20 tokens. You can automate the acceptance and withdrawal of cryptocurrency in your application.

You can contact me for help in integrating payment acceptance into your project.

Requirements

The following versions of PHP are supported by this version.

  • PHP 8.2 and older
  • Laravel 10 or older
  • PHP Extensions: Decimal, GMP, BCMath, CType.

Installation

You can install the package via composer:

composer require sakoora0x/laravel-tron-module

After you can run installer using command:

php artisan tron:install

And run migrations:

php artisan migrate

Register Service Provider and Facade in app, edit config/app.php:

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

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

For Laravel 10 you edit file app/Console/Kernel in method schedule(Schedule $schedule) add:

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

or for Laravel 11+ add this content to routes/console.php:

use Illuminate\Support\Facades\Schedule;

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

How use?

  1. Firstly register an account on the TronGrid website and get an API key.
  2. Using the following code, create a node through which the library will work:
$apiKey = "..."; // API Key from TronGrid.io
Tron::createTronGridNode($apiKey, 'node_name');
  1. Now you can create Tron Wallet using code:
$mnemonic = Tron::mnemonicGenerate();
echo 'Mnemonic: '.implode(' ', $mnemonic);

$wallet = Tron::createWallet('wallet_name', $mnemonic);
  1. Create primary Tron Address in your Wallet using code:
$address = Tron::createAddress($wallet, 'primary_address_name');

echo 'Primary Address: '.$address->address;
  1. Now you can send TRX using this code:
$to = 'receiver tron address';
$amount = 1;

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

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

If you want work with TRC-20

For example: Tether USDT

  1. You must create TronTRC20 model using this code:
$contractAddress = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';

$trc20Token = TronTRC20::create($contractAddress);
  1. For transfer Tether USDT TRC-20 for another address you can use this code:
$to = 'receiver tron address';
$amount = 1;

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

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

Commands

Synchronizing everything

php artisan tron:sync

Node synchronization

php artisan tron:sync-node NODE_ID

Wallet synchronization

php artisan tron:sync-wallet WALLET_ID

Address synchronization

php artisan tron:sync-address ADDRESS_ID

Create Tron Node. Before you need register account in https://trongrid.io and generate API Key.

php artisan tron:new-node

Create Tron Wallet.

php artisan tron:new-wallet

Generate Tron Address.

php artisan tron:new-address

Import watch only address.

php artisan tron:import-address

Create TRC-20 Token

php artisan tron:new-trc20

Testing

This package includes a comprehensive test suite built with Pest PHP.

Running Tests

# Run all tests
composer test

# Run tests with coverage
composer test-coverage

# Run specific test file
vendor/bin/pest tests/Unit/Support/KeyTest.php

Test Coverage

The test suite includes:

  • Unit Tests: Support classes, Models, API helpers, Casts, Enums
  • Feature Tests: Service provider, Facades, Wallet management workflows
  • 15 test files with 1,130+ lines of test code
  • 110 tests with 208+ assertions
  • Status: ✅ All tests passing
  • Automated CI/CD pipeline for PHP 8.2, 8.3 and 8.4 with Laravel 11.x and 12.x

For detailed testing documentation, see TESTING.md and tests/README.md.