mollsoft/laravel-tron-module
Composer 安装命令:
composer require mollsoft/laravel-tron-module
包简介
Laravel Tron Module
README 文档
README
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.1 and older
- Laravel 10 or older
- PHP Extensions: Decimal, GMP, BCMath, CType.
Installation
You can install the package via composer:
composer require mollsoft/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([ ..., \Mollsoft\LaravelTronModule\TronServiceProvider::class, ])->toArray(), 'aliases' => Facade::defaultAliases()->merge([ ..., 'Tron' => \Mollsoft\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?
- Firstly register an account on the TronGrid website and get an API key.
- Using the following code, create a node through which the library will work:
$apiKey = "..."; // API Key from TronGrid.io Tron::createTronGridNode($apiKey, 'node_name');
- Now you can create Tron Wallet using code:
$mnemonic = Tron::mnemonicGenerate(); echo 'Mnemonic: '.implode(' ', $mnemonic); $wallet = Tron::createWallet('wallet_name', $mnemonic);
- Create primary Tron Address in your Wallet using code:
$address = Tron::createAddress($wallet, 'primary_address_name'); echo 'Primary Address: '.$address->address;
- 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
- You must create TronTRC20 model using this code:
$contractAddress = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'; $trc20Token = TronTRC20::create($contractAddress);
- 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
mollsoft/laravel-tron-module 适用场景与选型建议
mollsoft/laravel-tron-module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.27k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「tron」 「mollsoft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mollsoft/laravel-tron-module 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mollsoft/laravel-tron-module 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mollsoft/laravel-tron-module 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
UsdtCloud TronService for PHP
Laravel Ethereum Module
This is my package laravel-telegram-bot
Alfabank REST API integration
Laravel Monero Module
tron apis for laravel
统计信息
- 总下载量: 1.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-03