PHPackages                             tron-energy-market/tronzap-sdk-php - 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. tron-energy-market/tronzap-sdk-php

ActiveLibrary[API Development](/categories/api)

tron-energy-market/tronzap-sdk-php
==================================

Official PHP SDK for TronZap.com. The TRON Energy API lets you buy energy to lower USDT (TRC20) transfer fees.

1.3.0(1mo ago)239↓75%1MITPHPPHP &gt;=7.4

Since Apr 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/tron-energy-market/tronzap-sdk-php)[ Packagist](https://packagist.org/packages/tron-energy-market/tronzap-sdk-php)[ Docs](https://tronzap.com)[ RSS](/packages/tron-energy-market-tronzap-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

Tron Energy Rental via API
==========================

[](#tron-energy-rental-via-api)

PHP SDK by TronZap.com
----------------------

[](#php-sdk-by-tronzapcom)

**[English](README.md)** | [Español](README.es.md) | [Português](README.pt-br.md) | [Русский](README.ru.md)

Official PHP SDK for the TronZap API. This SDK allows you to easily integrate with TronZap services for TRON energy rental.

TronZap.com allows you to [buy TRON energy](https://tronzap.com/), making USDT (TRC20) transfers cheaper by significantly reducing transaction fees.

👉 [Register for an API key](https://tronzap.com) to start using TronZap API and integrate it via the SDK.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require tron-energy-market/tronzap-sdk-php
```

Check out at Packagist:

Requirements
------------

[](#requirements)

- PHP 7.4 or higher

Usage
-----

[](#usage)

```
use TronZap\Client as TronZapClient;
use TronZap\Exception\TronZapException;

// Initialize the client
$apiToken = 'your_api_token';
$apiSecret = 'your_api_secret';
$client = new TronZapClient($apiToken, $apiSecret);

try {
    // Get account balance
    $balance = $client->getBalance();
    print_r($balance);

    // Get address info (resources and balances)
    $addressInfo = $client->getAddressInfo('TRX_ADDRESS');
    print_r($addressInfo);

    // Get available services
    $services = $client->getServices();
    print_r($services);

    // Estimate energy amount for USDT transfer
    $estimate = $client->estimateEnergy('FROM_TRX_ADDRESS', 'TO_TRX_ADDRESS', 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t');
    print_r($estimate);

    // Create an energy transaction
    $transaction = $client->createEnergyTransaction(
        'TRX_ADDRESS',       // TRON wallet address
        $estimate['energy'], // Energy amount
        1,                   // Duration (hours), can be 1 or 24
        'my-tx-id',          // External ID (optional)
        true                 // Activate address (optional)
    );
    print_r($transaction);

    // Buy bandwidth
    $bandwidth = $client->createBandwidthTransaction(
        'TRX_ADDRESS',   // TRON wallet address
        1000,            // Bandwidth amount
        'bandwidth-1'    // External ID (optional)
    );
    print_r($bandwidth);

    // Check transaction status
    $status = $client->checkTransaction($transaction['id']);
    print_r($status);

    // Create AML check for an address
    $amlCheck = $client->createAmlCheck(
        'address',
        'TRX',
        'TRX_ADDRESS'
    );
    print_r($amlCheck);

    // Check AML status
    $amlStatus = $client->checkAmlStatus($amlCheck['id']);
    print_r($amlStatus);
} catch (TronZapException $e) {
    echo "Error: " . $e->getMessage() . " (Code: " . $e->getCode() . ")\n";
}
```

Available Methods
-----------------

[](#available-methods)

- `getServices()` - Get list of available services and prices
- `getBalance()` - Get current account balance
- `getAddressInfo(address)` - Get address resources (energy, bandwidth) and balances (TRX, USDT)
- `createEnergyTransaction(address, energyAmount, duration, externalId, activateAddress)` - Create a transaction for energy purchase
- `createBandwidthTransaction(address, amount, externalId)` - Create a transaction for bandwidth purchase
- `createAddressActivationTransaction(address, externalId)` - Create a transaction for address activation
- `checkTransaction(transactionId, externalId)` - Check status of a transaction
- `getDirectRechargeInfo()` - Get direct recharge service information
- `getAmlServices()` - Get AML services and pricing
- `createAmlCheck(type, network, address, hash, direction)` - Create a new AML check
- `checkAmlStatus(id)` - Get status for an AML check
- `getAmlHistory(page, perPage, status)` - Get AML checks history

Error Handling
--------------

[](#error-handling)

The SDK uses a hierarchy of exceptions for precise error handling:

```
TronZapException
├── ApiException             — API-level errors (response code != 0)
├── NetworkException         — Network/connectivity errors
│   ├── ConnectionException  — Could not connect to server
│   ├── TimeoutException     — Request timed out
│   └── SslException         — SSL/TLS errors
└── HttpException            — HTTP non-2xx responses
    ├── RateLimitException   — HTTP 429 Too Many Requests
    ├── UnauthorizedException — HTTP 401/403
    └── ServerException      — HTTP 5xx errors

```

### Example

[](#example)

```
use TronZap\Client as TronZapClient;
use TronZap\Exception\ApiException;
use TronZap\Exception\ConnectionException;
use TronZap\Exception\HttpException;
use TronZap\Exception\NetworkException;
use TronZap\Exception\RateLimitException;
use TronZap\Exception\ServerException;
use TronZap\Exception\SslException;
use TronZap\Exception\TimeoutException;
use TronZap\Exception\TronZapException;
use TronZap\Exception\UnauthorizedException;

$client = new TronZapClient('your_api_token', 'your_api_secret');

try {
    $transaction = $client->createEnergyTransaction('TRX_ADDRESS', 65000, 1);
} catch (ApiException $e) {
    // API-level error (invalid params, insufficient funds, etc.)
    echo "API error [{$e->getCode()}]: {$e->getMessage()}\n";

    // Error key alias, e.g. "invalid_tron_address" or "invalid_tron_address.from_address"
    if ($e->getErrorKey()) {
        echo "Error key: {$e->getErrorKey()}\n";
    }

    if ($e->getCode() === TronZapException::INVALID_TRON_ADDRESS) {
        echo "Check the TRON address format.\n";
    }
} catch (RateLimitException $e) {
    echo "Too many requests, please slow down.\n";
} catch (UnauthorizedException $e) {
    echo "Invalid API token or signature.\n";
} catch (ServerException $e) {
    echo "TronZap server error [{$e->getStatusCode()}].\n";
} catch (HttpException $e) {
    echo "HTTP error [{$e->getStatusCode()}]: {$e->getMessage()}\n";
} catch (TimeoutException $e) {
    echo "Request timed out.\n";
} catch (SslException $e) {
    echo "SSL error: {$e->getMessage()}\n";
} catch (ConnectionException $e) {
    echo "Connection failed: {$e->getMessage()}\n";
} catch (NetworkException $e) {
    echo "Network error: {$e->getMessage()}\n";
} catch (TronZapException $e) {
    echo "Error [{$e->getCode()}]: {$e->getMessage()}\n";
}
```

### API Error Codes

[](#api-error-codes)

CodeConstantDescription1`AUTH_ERROR`Authentication error – Invalid API token or signature2`INVALID_SERVICE_OR_PARAMS`Invalid service or parameters5`WALLET_NOT_FOUND`Internal wallet not found. Contact support.6`INSUFFICIENT_FUNDS`Insufficient funds10`INVALID_TRON_ADDRESS`Invalid TRON address11`INVALID_ENERGY_AMOUNT`Invalid energy amount12`INVALID_DURATION`Invalid duration20`TRANSACTION_NOT_FOUND`Transaction not found24`ADDRESS_NOT_ACTIVATED`Address not activated25`ADDRESS_ALREADY_ACTIVATED`Address already activated30`AML_CHECK_NOT_FOUND`AML check not found35`SERVICE_NOT_AVAILABLE`Service not available500`INTERNAL_SERVER_ERROR`Internal server error – Contact supportTesting
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Support
-------

[](#support)

For support, please contact .

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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

Total

6

Last Release

42d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a82e29de1e0c44c88f8d2c8a40cbb7db38d9c72e5e6cf1c9aa724c0f323a34eb?d=identicon)[tron-energy-market](/maintainers/tron-energy-market)

---

Top Contributors

[![tron-energy-market](https://avatars.githubusercontent.com/u/204522373?v=4)](https://github.com/tron-energy-market "tron-energy-market (15 commits)")

---

Tags

buy-tron-energyenergy-apienergy-rental-apitron-blockchaintron-energytron-energy-apitron-protocoltrx-energytrx-energy-rentalusdt-apicryptocurrencyblockchaintrontron-apitrxtrc20USDTTronZapTrx APITRX energyTRON energy apibuy trx energybuy tron energytrx energy markettron energy marketTRC-20crypto transfersusdt energytether energy

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/tron-energy-market-tronzap-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/tron-energy-market-tronzap-sdk-php/health.svg)](https://phpackages.com/packages/tron-energy-market-tronzap-sdk-php)
```

###  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)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-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)
