diff --git a/examples/balance.php b/examples/balance.php index fc3957c..debaa00 100644 --- a/examples/balance.php +++ b/examples/balance.php @@ -1,9 +1,16 @@ setAddress('address'); +$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()); +} -$balance = $tron->getBalance(); -echo $tron->fromTron($balance); +$tron->setAddress('address'); +$balance = $tron->getBalance(null, true); \ No newline at end of file diff --git a/examples/custom-nodes.php b/examples/custom-nodes.php index fa49433..64e2c37 100644 --- a/examples/custom-nodes.php +++ b/examples/custom-nodes.php @@ -6,12 +6,12 @@ $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 -$tron = new Tron($fullNode, $solidityNode, $privateKey); - -//Example 2 -$tron->setFullNode($fullNode); -$tron->setSolidityNode($solidityNode); -$tron->setPrivateKey($privateKey); \ No newline at end of file +try { + $tron = new Tron($fullNode, $solidityNode, $eventServer, $privateKey); +} catch (\IEXBase\TronAPI\Exception\TronException $e) { + die($e->getMessage()); +} \ No newline at end of file diff --git a/examples/find-transaction.php b/examples/find-transaction.php index a6761ad..35630c8 100644 --- a/examples/find-transaction.php +++ b/examples/find-transaction.php @@ -1,7 +1,15 @@ getMessage()); +} $detail = $tron->getTransaction('TxId'); var_dump($detail); \ No newline at end of file diff --git a/examples/is-connection.php b/examples/is-connection.php index b3be552..5d4800c 100644 --- a/examples/is-connection.php +++ b/examples/is-connection.php @@ -2,14 +2,13 @@ include_once '../vendor/autoload.php'; $fullNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); -$solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io:8091'); +$solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); +$eventServer = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.trongrid.io'); -$tron = new \IEXBase\TronAPI\Tron(); - -if($fullNode->isConnected()) { - $tron->setFullNode($fullNode); +try { + $tron = new \IEXBase\TronAPI\Tron($fullNode, $solidityNode, $eventServer); +} catch (\IEXBase\TronAPI\Exception\TronException $e) { + exit($e->getMessage()); } -if($solidityNode->isConnected()) { - $tron->setSolidityNode($solidityNode); -} \ No newline at end of file +$tron->isConnected(); diff --git a/examples/option-trx.php b/examples/option-trx.php index c77b740..1ef36d2 100644 --- a/examples/option-trx.php +++ b/examples/option-trx.php @@ -1,9 +1,15 @@ getMessage()); +} //option 1 $tron->sendTransaction('from','to',0.1); @@ -12,4 +18,4 @@ $tron->send('from','to',0.1); //option 3 -$tron->sendTrx('from','to',0.1); \ No newline at end of file +$tron->sendTrx('from','to',0.1); diff --git a/examples/send-transaction-password.php b/examples/send-transaction-password.php deleted file mode 100644 index c7e8032..0000000 --- a/examples/send-transaction-password.php +++ /dev/null @@ -1,10 +0,0 @@ -sendTransactionByPassword('To Address',1,'Password'); - -echo '
';
-    print_r($transfer);
-echo '
'; diff --git a/examples/send-transaction.php b/examples/send-transaction.php index cd7bdf6..146e71b 100644 --- a/examples/send-transaction.php +++ b/examples/send-transaction.php @@ -1,12 +1,21 @@ getMessage()); +} + $tron->setAddress('address'); $tron->setPrivateKey('privateKey'); try { - $transfer = $tron->sendTransaction('FromAddress', 'ToAddress', 1); + $transfer = $tron->send( 'ToAddress', 1); } catch (\IEXBase\TronAPI\Exception\TronException $e) { die($e->getMessage()); } diff --git a/examples/transactionBuilder.php b/examples/transactionBuilder.php new file mode 100644 index 0000000..c0857b0 --- /dev/null +++ b/examples/transactionBuilder.php @@ -0,0 +1,19 @@ +getMessage()); +} + + +try { + $transaction = $tron->getTransactionBuilder()->sendTrx('to', 2,'fromAddress'); + $signedTransaction = $tron->signTransaction($transaction); + $response = $tron->sendRawTransaction($signedTransaction); +} catch (\IEXBase\TronAPI\Exception\TronException $e) { + die($e->getMessage()); +} diff --git a/src/Tron.php b/src/Tron.php index 87fee68..6cc484d 100644 --- a/src/Tron.php +++ b/src/Tron.php @@ -110,11 +110,20 @@ public function setManager($providers) { * Get provider manager * * @return TronManager - */ + */ public function getManager(): TronManager { return $this->manager; } + /** + * Get Transaction Builder + * + * @return TransactionBuilder + */ + public function getTransactionBuilder(): TransactionBuilder { + return $this->transactionBuilder; + } + /** * Check connected provider * @@ -197,8 +206,18 @@ public function getAddress(): array * Get customized provider data * * @return array - */ + */ public function providers(): array + { + return $this->manager->getProviders(); + } + + /** + * Check Connection Providers + * + * @return array + */ + public function isConnected(): array { return $this->manager->isConnected(); }