https://github.com/iexbase/tron-api
A PHP API for interacting with Tron (TRX)
https://github.com/iexbase/tron-api
php tron tron-api tron-library tron-protocol tron-rest tron-wallet tronscan
Last synced: 10 days ago
JSON representation
A PHP API for interacting with Tron (TRX)
- Host: GitHub
- URL: https://github.com/iexbase/tron-api
- Owner: iexbase
- License: mit
- Created: 2018-09-11T08:25:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T17:26:13.000Z (over 1 year ago)
- Last Synced: 2026-01-13T22:57:57.553Z (10 days ago)
- Topics: php, tron, tron-api, tron-library, tron-protocol, tron-rest, tron-wallet, tronscan
- Language: PHP
- Homepage: https://iexbase.github.io/tron-api/
- Size: 196 KB
- Stars: 437
- Watchers: 19
- Forks: 331
- Open Issues: 103
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TRON API
A PHP API for interacting with the Tron Protocol
[](https://packagist.org/packages/iexbase/tron-api)
[](LICENSE)
[](https://travis-ci.com/iexbase/tron-api)
[](https://github.com/iexbase/tron-api/graphs/contributors)
[](https://packagist.org/packages/iexbase/tron-api)
## Install
```bash
> composer require iexbase/tron-api --ignore-platform-reqs
```
## Requirements
The following versions of PHP are supported by this version.
* PHP 7.4
## Example Usage
```php
use IEXBase\TronAPI\Tron;
$fullNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
$solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
$eventServer = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io');
try {
$tron = new \IEXBase\TronAPI\Tron($fullNode, $solidityNode, $eventServer);
} catch (\IEXBase\TronAPI\Exception\TronException $e) {
exit($e->getMessage());
}
$this->setAddress('..');
//Balance
$tron->getBalance(null, true);
// Transfer Trx
var_dump($tron->send('to', 1.5));
//Generate Address
var_dump($tron->createAccount());
//Get Last Blocks
var_dump($tron->getLatestBlocks(2));
//Change account name (only once)
var_dump($tron->changeAccountName('address', 'NewName'));
// Contract
$tron->contract('Contract Address');
```
## Testing
``` bash
$ vendor/bin/phpunit
```
## Donations
**Tron(TRX)**: TRWBqiqoFZysoAeyR1J35ibuyc8EvhUAoY