manojx/tron-bundle
Composer 安装命令:
composer require manojx/tron-bundle
包简介
A Symfony bundle to interact with Tron Blockchain and Wallets.
README 文档
README
A Symfony bundle that makes it easy to interact with the Tron Blockchain. It allows you to manage wallets, create and sign transactions, broadcast them to the network, and handle tasks like generating and validating addresses. This bundle simplifies working with Tron in Symfony applications.
Features
- Create and manage Tron wallets
- Sign transactions and broadcast them to the Tron network
- Create new Tron addresses and validate them
- Easy integration with Symfony applications
Installation
To install the Tron bundle, use Composer:
composer require manojx/tron-bundle
Requirements
- PHP
^7.4 || ^8.0 - Symfony
^5.4 || ^6.1 || ^7.0 - simplito/elliptic-php
^1.0 - kornrunner/keccak
^1.1
Configuration
You can configure the Tron node endpoint in your Symfony configuration:
# config/packages/tron.yaml tron: default_network: shasta networks: mainnet: fullNode: host: 'https://api.trongrid.io' api_key: 'api-key' solidityNode: host: 'https://api.trongrid.io' api_key: 'api-key' explorer: host: 'https://tronscan.org' api_key: 'api-key' shasta: fullNode: host: 'https://api.shasta.trongrid.io' api_key: 'api-key' explorer: host: 'https://shastapi.tronscan.org' nile: fullNode: host: 'https://api.nileex.io' api_key: 'api-key' explorer: host: 'https://nile.tronscan.org'
Usage
Creating a Tron Wallet
You can use the Tron service to create a new wallet or access an existing wallet.
use ManojX\TronBundle\TronInterface; class WalletService { private TronInterface $tron; public function __construct(TronInterface $tron) { $this->tron = $tron; } public function createWallet() { $wallet = $this->tron->getWallet(); $address = $wallet->createNewAddress(); echo 'Address: ' . $address->getAddress(); echo 'Private Key: ' . $address->getPrivateKey(); } }
Sending TRX
You can initialize a transaction and send TRX using the wallet's private key.
use ManojX\TronBundle\TronInterface; class TransactionService { private TronInterface $tron; public function __construct(TronInterface $tron) { $this->tron = $tron; } public function sendTrx() { $wallet = $this->tron->getWallet('your-private-key'); $transaction = $wallet->initTransaction(); $transaction->setTo('receiver-tron-address'); $transaction->setAmount(1); // Amount in TRX $signedTransaction = $transaction->createAndSign(); $node = $this->tron->getNode(); $response = $node->broadcastTransaction($signedTransaction); return $response; } }
USDT & Contract Interaction
You can interact with USDT and other smart contracts on the Tron network.
USDT Contract Address: TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs (Shasta Testnet)
use ManojX\TronBundle\TronInterface; class TransactionService { private TronInterface $tron; public function __construct(TronInterface $tron) { $this->tron = $tron; } public function sendUsdt() { $wallet = $this->tron->getWallet('your-private-key'); $usdt = $wallet->getUsdt(); $transaction = $usdt->transfer('to-address', 1); $signedTransaction = $wallet->signTransaction($transaction['data']); $response = $node->broadcastTransaction($signedTransaction); return $response; } }
For additional usage examples, please refer to the examples directory.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.
manojx/tron-bundle 适用场景与选型建议
manojx/tron-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 76 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「bundle」 「wallet」 「blockchain」 「tron」 「tronlink」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 manojx/tron-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 manojx/tron-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 manojx/tron-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
Library for validation of cryptocoin wallets
统计信息
- 总下载量: 76
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-07