Open jomagalo opened 2 years ago
Following the example indicating to create a trc20 wallet, it is created correctly.
use GuzzleHttp\Client; $uri = 'https://api.trongrid.io';// mainnet // $uri = 'https://api.shasta.trongrid.io';// shasta testnet $api = new \Tron\Api(new Client(['base_uri' => $uri])); $trxWallet = new \Tron\TRX($api); $addressData = $trxWallet->generateAddress(); // $addressData->privateKey // $addressData->address $config = [ 'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20 'decimals' => 6, ]; $trc20Wallet = new \Tron\TRC20($api, $config); $addressData = $trc20Wallet->generateAddress();
But I try to modify the same code to get the balance and it gives errors.
These are the unsuccessful tests:
use GuzzleHttp\Client; $uri = 'https://api.trongrid.io';// mainnet // $uri = 'https://api.shasta.trongrid.io';// shasta testnet $api = new \Tron\Api(new Client(['base_uri' => $uri])); $wallet = "TXXXXX..."; $trxWallet = new \Tron\TRX($api); $balance = $trxWallet->balance($wallet); // $addressData->privateKey // $addressData->address $config = [ 'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20 'decimals' => 6, ]; $trc20Wallet = new \Tron\TRC20($api, $config); $balance = $trc20Wallet->balance($wallet);
I have also tried like this:
use GuzzleHttp\Client; $uri = 'https://api.trongrid.io';// mainnet // $uri = 'https://api.shasta.trongrid.io';// shasta testnet $api = new \Tron\Api(new Client(['base_uri' => $uri])); $wallet = "TXXXXX..."; $trxWallet = new \Tron\TRX($api); $balance = $trxWallet->balance(Address $wallet); // $addressData->privateKey // $addressData->address $config = [ 'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20 'decimals' => 6, ]; $trc20Wallet = new \Tron\TRC20($api, $config); $balance = $trc20Wallet->balance(Address $wallet);
https://github.com/Fenguoz/tron-php/blob/master/tests/TRC20Test.php#L59
Following the example indicating to create a trc20 wallet, it is created correctly.
But I try to modify the same code to get the balance and it gives errors.
These are the unsuccessful tests:
I have also tried like this: