Fenguoz / tron-php

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
MIT License
194 stars 65 forks source link

Transfer Fail #32

Closed guejif closed 2 years ago

guejif commented 2 years ago

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 :)

guejif commented 2 years ago

There are 2 dollars on the wallet from which the sending takes place

guejif commented 2 years ago

I realized I didn't have enough Energy and Bandwidth