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

Dose it support iexbase/tron-api 3.1? #1

Closed jacktop closed 3 years ago

jacktop commented 3 years ago

Dose it support iexbase/tron-api 3.1?

Fenguoz commented 3 years ago

image The program can run normally

Fenguoz commented 3 years ago

tag 0.1.5

jacktop commented 3 years ago

Thank you very much for your answer. Can you provide some TRC20 transfer examples?

Fenguoz commented 3 years ago
<?php
include_once './vendor/autoload.php';

use GuzzleHttp\Client;
use Tron\Address;

$uri = 'https://api.shasta.trongrid.io';// shasta testnet
$api = new \Tron\Api(new Client(['base_uri' => $uri]));

$config = [
    'contract_address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',// USDT TRC20
    'decimals' => 6,
];
$trc20Wallet = new \Tron\TRC20($api, $this->config);

$fromPrivateKey = '0xfc0df27bf59f39d37726ba4****';// The private key of the sending address
$toAddress = 'TPQz2D5PddZ1LTi****';// Receiving address
$amount = 1;// The number of transactions, but it is necessary to ensure that the TRX of the sending address has sufficient transaction fees

$from = $trc20Wallet->privateKeyToAddress($fromPrivateKey);
$to = new Address($toAddress, '', $trc20Wallet->tron->address2HexString($toAddress));
$transferResult = $trc20Wallet->transfer($from, $to, $amount);
boneng commented 2 years ago

Using version ^1.3 for fenguoz/tron-php Root package 'fenguoz/tron-php' cannot require itself in its composer.json can youe help me?