PHPackages                             just-luka/php-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. [HTTP &amp; Networking](/categories/http)
4. /
5. just-luka/php-tron

ActiveLibrary[HTTP &amp; Networking](/categories/http)

just-luka/php-tron
==================

PHP package for interacting with TRX network

v2.0.0(2mo ago)324MITPHPPHP &gt;=8.2

Since Mar 5Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/just-Luka/php-tron)[ Packagist](https://packagist.org/packages/just-luka/php-tron)[ RSS](/packages/just-luka-php-tron/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (9)Versions (10)Used By (0)

  [![PHP](https://camo.githubusercontent.com/ac1e0a5c4e9856771e9209edfa09a82f2ccbb1b1711e0ee426482958b4302967/68747470733a2f2f6a7573742d6c756b612e6769746875622e696f2f7068702e737667)](https://camo.githubusercontent.com/ac1e0a5c4e9856771e9209edfa09a82f2ccbb1b1711e0ee426482958b4302967/68747470733a2f2f6a7573742d6c756b612e6769746875622e696f2f7068702e737667) [![X](https://camo.githubusercontent.com/0523089ddf215b9937de9c2679a07f92892cdbfb8e8c2dccf6d8f5c09090e5db/68747470733a2f2f6a7573742d6c756b612e6769746875622e696f2f782d6d61726b2d3531322e706e67)](https://camo.githubusercontent.com/0523089ddf215b9937de9c2679a07f92892cdbfb8e8c2dccf6d8f5c09090e5db/68747470733a2f2f6a7573742d6c756b612e6769746875622e696f2f782d6d61726b2d3531322e706e67) [![TronGrid](https://camo.githubusercontent.com/7729489add0e164a45a38df37e51e0f4dbe678cc3964dc021763060644159044/68747470733a2f2f6a7573742d6c756b612e6769746875622e696f2f74726f6e677269642e706e67)](https://camo.githubusercontent.com/7729489add0e164a45a38df37e51e0f4dbe678cc3964dc021763060644159044/68747470733a2f2f6a7573742d6c756b612e6769746875622e696f2f74726f6e677269642e706e67)

 [![Stable Version](https://camo.githubusercontent.com/90a28d6ff2bccc57920f06c7db37bd76f6a3e934c8117182aa218d4522bf125d/68747470733a2f2f706f7365722e707567782e6f72672f6a7573742d4c756b612f7068702d74726f6e2f762f737461626c65)](https://github.com/just-Luka/php-tron/releases) [![Php Version](https://camo.githubusercontent.com/c05d077e0b98ebba55e8a3b2f37d37a2acef281c74f4378dbb4d5052186faf25/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d382e322d3839393362652e7376673f6d61784167653d32353932303030)](https://www.php.net) [![php-tron License](https://camo.githubusercontent.com/11b57809b0bff72973083eb32c621c5aa9bda2b6d991af51cd0fd39d081e41f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a7573742d4c756b612f7068702d74726f6e2e7376673f6d61784167653d32353932303030)](https://github.com/just-Luka/php-tron/blob/main/LICENSE)

A PHP library for interacting with the TRON blockchain.
=======================================================

[](#a-php-library-for-interacting-with-the-tron-blockchain)

Package provides user-friendly extension API. The latest version of TronGrid's proprietary API is v1. TronGrid API service has the features of low latency, high consistency, high availability and partition fault tolerance.

**Note:** In order to ensure the reasonable allocation of requested resources, all request APIs need to include the [**API Key**](https://www.trongrid.io/dashboard/keys) parameter.

> Requests **without an API Key** will be severely limited or may not receive a response.

### Features

[](#features)

- Generate TRON address
- Check account balance
- Check transaction details
- List assets from chain
- List transactions by contract address

### Installation

[](#installation)

Install the package via Composer:

```
composer require just-Luka/php-tron
```

### Setup

[](#setup)

Initialize the client (Mainnet):

```
use Trx\TrxClient;

$tron = new TrxClient(apiKey: 'YOUR-API-KEY');
```

Initialize the client (Shasta Testnet):

```
use Trx\TrxClient;

$tron = new TrxClient(apiKey: 'YOUR-API-KEY', testMode: true);
```

---

### Wallet

[](#wallet)

Generate a single TRON address:

```
$wallet = $tron->wallet()->create();

echo $wallet->getAddress();    // T...
echo $wallet->getPrivateKey(); // 64-char hex
```

Generate multiple addresses at once:

```
$wallets = $tron->wallet()->createMultiple(5);

foreach ($wallets as $wallet) {
    echo $wallet->getAddress();
}
```

---

### Account

[](#account)

Fetch account info and balance:

```
$account = $tron->account('TDrbCtdTj5KMo67mtQw2XXu5eTqwwVYoKz')->explore();

echo $account->balance;             // SUN (1 TRX = 1,000,000 SUN)
echo $account->address;
echo $account->createTime;
echo $account->netWindowSize;
echo $account->ownerPermissionThreshold;
echo $account->activePermissionThreshold;

// Energy & bandwidth resources
echo $account->resource->energyWindowSize;
echo $account->resource->energyUsage;
echo $account->resource->energyWindowOptimized;

// TRC20 token balances  [ ['token_contract_address' => balance], ... ]
var_dump($account->trc20);
```

Fetch TRX transfer blocks for an account:

```
$blocks = $tron->account('TDrbCtdTj5KMo67mtQw2XXu5eTqwwVYoKz')->blocks();

foreach ($blocks as $block) {
    echo $block->txID;
    echo $block->blockNumber;
    echo $block->blockTimestamp;
    echo $block->contractBalance;
    echo $block->contractOwnerAddress;
    echo $block->contractReceiverAddress;
    echo $block->netFee;
    echo $block->energyFee;
}
```

Fetch TRC20 transactions for an account:

```
$transactions = $tron->account('TDrbCtdTj5KMo67mtQw2XXu5eTqwwVYoKz')->transactions();

foreach ($transactions as $tx) {
    echo $tx->transactionId;
    echo $tx->from;
    echo $tx->to;
    echo $tx->value;
    echo $tx->blockTimestamp;
    echo $tx->type;

    // Token info
    echo $tx->tokenInfo->symbol;
    echo $tx->tokenInfo->name;
    echo $tx->tokenInfo->decimals;
    echo $tx->tokenInfo->address;
}
```

---

### Contract

[](#contract)

Fetch transactions for a contract address:

```
$contract = $tron->contract('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t');

$blocks = $contract->blocks();
$tokens = $contract->tokens();
```

---

### Assets

[](#assets)

```
$asset = $tron->asset();

$all     = $asset->all();               // all assets
$byName  = $asset->byName('BitTorrent'); // by name (may return multiple)
$byId    = $asset->byId(1000001);        // by ID or owner address
```

Each `Asset` object contains:

```
$asset->id;
$asset->name;
$asset->abbr;
$asset->description;
$asset->url;
$asset->totalSupply;
$asset->precision;
$asset->ownerAddress;
$asset->startTime;
$asset->endTime;
```

---

### Filters

[](#filters)

Filters can be chained on `account()` and `contract()` calls before executing a query.
Calling the same filter twice overwrites the previous value.

MethodParameterDescription`filterOnlyConfirmed()`—Return only confirmed transactions. Cannot be combined with `filterOnlyUnconfirmed()`.`filterOnlyUnconfirmed()`—Return only unconfirmed transactions. Cannot be combined with `filterOnlyConfirmed()`.`filterLimit(int)``1–200` (default `20`)Number of results per page.`filterFingerprint(string)`fingerprint from previous responsePagination cursor. Other filters must remain the same across pages.`filterOrderBy(string)``block_timestamp,asc` | `block_timestamp,desc`Sort order (default `desc`).`filterMinTimestamp(string)`Unix ms timestampReturn results after this timestamp.`filterMaxTimestamp(string)`Unix ms timestampReturn results before this timestamp.`filterContractAddress(string)`Base58 or hex addressFilter by a specific token contract.`filterOnlyTo()`—Only transactions **to** this address.`filterOnlyFrom()`—Only transactions **from** this address.Example — paginate confirmed USDT transfers in a time window:

```
$account = $tron->account('TDrbCtdTj5KMo67mtQw2XXu5eTqwwVYoKz');

$transactions = $account
    ->filterOnlyConfirmed()
    ->filterLimit(50)
    ->filterContractAddress('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t') // USDT
    ->filterMinTimestamp('1700000000000')
    ->filterMaxTimestamp('1710000000000')
    ->filterOrderBy('block_timestamp,asc')
    ->transactions();
```

Fetch the next page using the fingerprint from the last result:

```
$lastTx      = end($transactions);
$nextPage    = $account
    ->filterOnlyConfirmed()
    ->filterLimit(50)
    ->filterFingerprint($lastTx->transactionId)
    ->transactions();
```

---

### Error Handling

[](#error-handling)

```
use Trx\Domain\Exceptions\ApiRequestException;
use Trx\Domain\Exceptions\InvalidTronAddressException;

try {
    $account = $tron->account('invalid-address');
} catch (InvalidTronAddressException $e) {
    // Thrown immediately when the address format is invalid (no API call made)
}

try {
    $result = $tron->account('TDrbCtdTj5KMo67mtQw2XXu5eTqwwVYoKz')->explore();
    // Returns null if the account does not exist on-chain
} catch (ApiRequestException $e) {
    // Thrown on non-200 API responses or network failures
    echo $e->getMessage();
}
```

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance87

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~70 days

Recently: every ~105 days

Total

7

Last Release

63d ago

Major Versions

v1.1.1 → v2.0.02026-05-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/56077514?v=4)[Luka](/maintainers/just-luka)[@just-Luka](https://github.com/just-Luka)

---

Top Contributors

[![just-Luka](https://avatars.githubusercontent.com/u/56077514?v=4)](https://github.com/just-Luka "just-Luka (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/just-luka-php-tron/health.svg)

```
[![Health](https://phpackages.com/badges/just-luka-php-tron/health.svg)](https://phpackages.com/packages/just-luka-php-tron)
```

###  Alternatives

[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M92](/packages/mezzio-mezzio-router)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

1110.7k7](/packages/hardcastle-xrpl-php)

PHPackages © 2026

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