PHPackages                             anonymhk/tronapi - 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. anonymhk/tronapi

ActiveLibrary[API Development](/categories/api)

anonymhk/tronapi
================

Support TRON's TRX and TRC20, A PHP library to create Tron wallet addresses and manage wallets using the Tron API

v5.2.2(2y ago)303677[1 issues](https://github.com/AnonymHK/TronApi/issues)MITPHPPHP ^8.0

Since Sep 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AnonymHK/TronApi)[ Packagist](https://packagist.org/packages/anonymhk/tronapi)[ Docs](https://github.com/anonymhk/tronapi)[ RSS](/packages/anonymhk-tronapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (29)Used By (0)

概述
--

[](#概述)

波场API 接口封装, 目前支持波场的 TRX 和 TRC20 中常用生成地址，发起转账，离线签名等功能. 库基于官方Tron API实现, 除密码学ECC库外无第三方依赖引用.

特点
--

[](#特点)

1. 一套写法兼容 TRON 网络中 TRX 货币和 TRC 系列所有通证
2. 接口方法可可灵活增减

Tips: php版本最低支持8.0且需要安装GMP扩展!

支持方法
----

[](#支持方法)

- 生成地址 `generateAddress()`
- 生成带助记词的钱包地址 `generateAddressWithMnemonic()`
- 从私钥获取助记词 `getPhraseFromPrivateKey()`
- 从助记词获取私钥 `getPrivateKeyFromPhrase()`
- 从公钥获取钱包地址 `getAddressHexFromPublicKey()`
- 使用Net方式验证钱包地址 `validateAddress()`
- 获取账户信息 `accountInfo(string $address)`
- 使用TXID获取交易信息 `getTransactionInfoById(string $txid)`
- 私钥获取钱包地址 `getAddressByPrivateKey(string $privateKeyHex)`
- 查询TRX余额 `balance(string $address)`
- 查询Token余额 `$trc20->balance(string $address)`
- 交易转账(离线签名、带转账备注) `transfer(string $private_key, string $from, string $to, float $amount, string $message = null)`
- TRC20交易转账(离线签名、带转账备注) `transferTRC20(string $private_key, string $from, string $to, float $amount, string $message = null, float $fee_limit = 150000000)`
- 查询最新区块 `getNowBlock()`
- 使用blockID获取区块信息 `getBlockByNum(int $blockID)`
- 根据交易哈希查询信息 `getTransactionById(string $txHash)`
- 查询钱包地址交易记录 `getTransactionsByAddress(string $address,int $limit = 20)`
- 快捷方法: 获取钱包支出记录 `getTransactionsFromAddress(string $address)` 获取钱包收入记录 `getTransactionsToAddress(string $address)`
- 查询TRC20地址交易记录 `getTransactionsByTrc20(string $address, int $mintimestamp = null, int $maxtimestamp = null, bool $confirmed = null, bool $to = false,bool $from = false, $limit = 20)`

快速开始
----

[](#快速开始)

### 安装

[](#安装)

```
> composer require anonymhk/tronApi
```

### 接口调用

[](#接口调用)

```
# ApiKey需自行申请
# Mainnet：		https://api.trongrid.io
# Shasta Testnet:	https://api.shasta.trongrid.io
# Nile Testnet:	https://nile.trongrid.io

$uri = 'https://api.shasta.trongrid.io';// shasta testnet
$trxWallet = new TRX(apiurl: $uri);

$addressData = $trxWallet->generateAddress();
var_dump($addressData);

$option = [
	'headers' => [
        'TRON-PRO-API-KEY' => ApiSecret,
        'Content-Type' => 'application/json'
    ],
    'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20
    'decimals' => 6,
];
$trc20Wallet = new TRC20(apiurl: $uri, option: $option);
$addressData = $trc20Wallet->balance(ADDRESS);
var_dump($addressData);
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 82.1% 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 ~81 days

Recently: every ~47 days

Total

26

Last Release

765d ago

Major Versions

v1.3.7 → v2.0.12018-11-06

v2.0.7 → v3.02020-09-23

v3.1.2 → 4.02021-05-29

4.0.1 → v5.0.02022-10-18

PHP version history (6 changes)v1.0PHP ^7.1

v3.1.2PHP ^7.2

4.0PHP ^7.3

4.0.1PHP ^7.4

v5.0.0PHP &gt;=8.0

v5.2.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d1325d6264b247c1cc9aa38aac2de4dc4f5cecb2bddfc7bdabafa46abc0e209?d=identicon)[AnonymHK](/maintainers/AnonymHK)

---

Top Contributors

[![serderovsh](https://avatars.githubusercontent.com/u/24723913?v=4)](https://github.com/serderovsh "serderovsh (248 commits)")[![AnonymHK](https://avatars.githubusercontent.com/u/110597435?v=4)](https://github.com/AnonymHK "AnonymHK (20 commits)")[![1099511627776](https://avatars.githubusercontent.com/u/2117414?v=4)](https://github.com/1099511627776 "1099511627776 (19 commits)")[![kaankozan](https://avatars.githubusercontent.com/u/38933295?v=4)](https://github.com/kaankozan "kaankozan (9 commits)")[![sharifzadesina](https://avatars.githubusercontent.com/u/205923701?v=4)](https://github.com/sharifzadesina "sharifzadesina (3 commits)")[![sashabeton](https://avatars.githubusercontent.com/u/23243361?v=4)](https://github.com/sashabeton "sashabeton (2 commits)")[![dogdev](https://avatars.githubusercontent.com/u/4762407?v=4)](https://github.com/dogdev "dogdev (1 commits)")

---

Tags

phptrontrxtrc20

### Embed Badge

![Health badge](/badges/anonymhk-tronapi/health.svg)

```
[![Health](https://phpackages.com/badges/anonymhk-tronapi/health.svg)](https://phpackages.com/packages/anonymhk-tronapi)
```

###  Alternatives

[fenguoz/tron-php

Support TRON's TRX and TRC20, which include functions such as address creation, balance query, transaction transfer, query the latest blockchain, query information based on the blockchain, and query information based on the transaction hash

21436.6k1](/packages/fenguoz-tron-php)[drlecks/simple-web3-php

Web3 library in PHP

7641.6k2](/packages/drlecks-simple-web3-php)[takpesar/tron

A PHP library to create Tron wallet addresses and manage wallets using the Tron API

183.2k](/packages/takpesar-tron)

PHPackages © 2026

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