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
An error occurs:
Fatal error: Uncaught Tron\Exceptions\TransactionException: Transfer Fail in E:\Programs\OpenServer\domains\localhost.tron\vendor\fenguoz\tron-php\src\TRC20.php:90 Stack trace: #0 E:\Programs\OpenServer\domains\localhost.tron\index.php(39): Tron\TRC20->transfer() #1 E:\Programs\OpenServer\domains\localhost.tron\index.php(45): TRC20transfer() #2 {main} thrown in E:\Programs\OpenServer\domains\localhost.tron\vendor\fenguoz\tron-php\src\TRC20.php on line 90
Hi, I have a code:
`require_once DIR . '/vendor/autoload.php';
use GuzzleHttp\Client;
$uri = 'https://api.trongrid.io'; // mainnet $api = new \Tron\Api(new Client(['base_uri' => $uri]));
$trc20Wallet = new \Tron\TRC20($api, [ 'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', // USDT TRC20 'decimals' => 6, ]);
function TRC20transfer($privateKey, $to_address, $amount){ global $trc20Wallet; $from = $trc20Wallet->privateKeyToAddress($privateKey); $to = new \Tron\Address( $to_address, '', $trc20Wallet->tron->address2HexString($to_address) ); $test = $trc20Wallet->transfer($from, $to, $amount); return var_dump($test); } $privateKey = privateKey; echo TRC20transfer($privateKey, 'TNm...', 1);`
An error occurs: Fatal error: Uncaught Tron\Exceptions\TransactionException: Transfer Fail in E:\Programs\OpenServer\domains\localhost.tron\vendor\fenguoz\tron-php\src\TRC20.php:90 Stack trace: #0 E:\Programs\OpenServer\domains\localhost.tron\index.php(39): Tron\TRC20->transfer() #1 E:\Programs\OpenServer\domains\localhost.tron\index.php(45): TRC20transfer() #2 {main} thrown in E:\Programs\OpenServer\domains\localhost.tron\vendor\fenguoz\tron-php\src\TRC20.php on line 90
plz help :)