-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
5,085 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# User-specific stuff | ||
.idea | ||
# CMake | ||
cmake-build-*/ | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
examples/index.php | ||
composer.lock | ||
examples/index2.php | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: php | ||
|
||
php: | ||
- 7.4 | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
before_install: | ||
- travis_retry composer self-update | ||
|
||
install: | ||
- travis_retry composer install --no-interaction --prefer-dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-cayman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"constant":false,"inputs":[{"name":"number","type":"uint256"}],"name":"fibonacciNotify","outputs":[{"name":"result","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"number","type":"uint256"}],"name":"fibonacci","outputs":[{"name":"result","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"uint256"},{"indexed":false,"name":"result","type":"uint256"}],"name":"Notify","type":"event"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "fourclub/tron-api", | ||
"description": "PHP API for interacting with Tron (Trx)", | ||
"license": "MIT", | ||
"type": "library", | ||
"homepage": "https://github.com/fourclub/tron-api", | ||
"require": { | ||
"php": "^7.4", | ||
"comely-io/data-types": "^1.0", | ||
"guzzlehttp/guzzle": "^7.0", | ||
"iexbase/web3.php": "^2.0.1", | ||
"kornrunner/secp256k1": "^0.1.2", | ||
"simplito/elliptic-php": "^1.0", | ||
"ext-json": "*", | ||
"ext-bcmath": "*" | ||
}, | ||
|
||
"require-dev": { | ||
"phpunit/phpunit": "^6.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"fourclub\\TronAPI\\": "src" | ||
} | ||
}, | ||
|
||
"autoload-dev": { | ||
"psr-4": { | ||
"fourclub\\TronAPI\\Test\\": "tests" | ||
} | ||
}, | ||
|
||
"config": { | ||
"sort-packages": true | ||
}, | ||
|
||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron(); | ||
|
||
$generateAddress = $tron->generateAddress(); // or createAddress() | ||
$isValid = $tron->isAddress($generateAddress->getAddress()); | ||
|
||
|
||
echo 'Address hex: ' . $generateAddress->getAddress(); | ||
echo 'Address base58: ' . $generateAddress->getAddress(true); | ||
echo 'Private key: ' . $generateAddress->getPrivateKey(); | ||
echo 'Public key: ' . $generateAddress->getPublicKey(); | ||
echo 'Is Validate: ' . $isValid; | ||
|
||
echo 'Raw data: ' . $generateAddress->getRawData(); | ||
|
||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$tron = new \fourclub\TronAPI\Tron(); | ||
|
||
/** | ||
* WARNING: When sending funds, you should not specify these parameters | ||
* | ||
* P.S: In the process of payment are automatically converted | ||
*/ | ||
|
||
$from = $tron->toTron(1.15); //1150000 | ||
$to = $tron->fromTron(11500000); //11.5000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
$tron->setAddress('address'); | ||
$balance = $tron->getBalance(null, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
include_once '../vendor/autoload.php'; | ||
|
||
use fourclub\TronAPI\Tron; | ||
|
||
try { | ||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
||
try { | ||
$tron = new Tron($fullNode, $solidityNode, $eventServer, null, true); | ||
$contract = $tron->contract('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'); // Tether USDT https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t | ||
|
||
// Data | ||
echo $contract->name(); | ||
echo $contract->symbol(); | ||
echo $contract->balanceOf(); | ||
echo $contract->totalSupply(); | ||
//echo $contract->transfer('to', 'amount', 'from'); | ||
|
||
|
||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
$balance = $tron->getTransactionBuilder()->contractbalance($tron->getAddress); | ||
foreach ($balance as $key => $item) { | ||
echo $item["name"] . " (" . $item["symbol"] . ") => " . $item["balance"] . "\n"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
use fourclub\TronAPI\Provider\HttpProvider; | ||
use fourclub\TronAPI\Tron; | ||
|
||
$fullNode = new HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new HttpProvider('https://api.trongrid.io'); | ||
$privateKey = 'private_key'; | ||
|
||
//Example 1 | ||
try { | ||
$tron = new Tron($fullNode, $solidityNode, $eventServer, $privateKey); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
die($e->getMessage()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
$detail = $tron->getTransaction('TxId'); | ||
var_dump($detail); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$tron = new \fourclub\TronAPI\Tron(); | ||
|
||
$tron->toHex('TT67rPNwgmpeimvHUMVzFfKsjL9GZ1wGw8'); | ||
//result: 41BBC8C05F1B09839E72DB044A6AA57E2A5D414A10 | ||
|
||
$tron->fromHex('41BBC8C05F1B09839E72DB044A6AA57E2A5D414A10'); | ||
//result: TT67rPNwgmpeimvHUMVzFfKsjL9GZ1wGw8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
$tron->isConnected(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
//option 1 | ||
$tron->sendTransaction('to', 0.1, 'hello'); | ||
|
||
//option 2 | ||
$tron->send('to', 0.1); | ||
|
||
//option 3 | ||
$tron->sendTrx('to', 0.1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
$tron->setAddress('address'); | ||
$tron->setPrivateKey('privateKey'); | ||
|
||
try { | ||
$transfer = $tron->send('ToAddress', 1); | ||
$transfer = $tron | ||
->contract('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t') // tether contract address | ||
->setFeeLimit(15); // fee limit 15 trx o more AND | ||
// send "USDT amount" to " USDT address" | ||
$result = $transfer->transfer('address To', 'USDT amount'); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
die($e->getMessage()); | ||
} | ||
|
||
var_dump($transfer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
include_once '../vendor/autoload.php'; | ||
|
||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
$tron->setAddress('address'); | ||
$tron->setPrivateKey('privateKey'); | ||
|
||
try { | ||
$transfer = $tron->send('ToAddress', 1); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
die($e->getMessage()); | ||
} | ||
|
||
var_dump($transfer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
$fullNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$solidityNode = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
$eventServer = new \fourclub\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); | ||
|
||
try { | ||
$tron = new \fourclub\TronAPI\Tron($fullNode, $solidityNode, $eventServer); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
exit($e->getMessage()); | ||
} | ||
|
||
|
||
try { | ||
$transaction = $tron->getTransactionBuilder()->sendTrx('to', 2, 'fromAddress'); | ||
$signedTransaction = $tron->signTransaction($transaction); | ||
$response = $tron->sendRawTransaction($signedTransaction); | ||
} catch (\fourclub\TronAPI\Exception\TronException $e) { | ||
die($e->getMessage()); | ||
} |
Oops, something went wrong.