nature6016/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

v1.0.1 2023-01-22 17:36 UTC

This package is auto-updated.

Last update: 2024-10-22 21:23:33 UTC


README

English | 中文

TRON-PHP

Php Version Hyperf License

Introduction

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

Advantage

  1. One set of scripts is compatible with all TRX currencies and TRC20 certifications in the TRON network
  2. Interface methods can be added or subtracted flexibly

Support Method

  • Generate address generateAddress()
  • Verify address validateAddress(Address $address)
  • Get the address according to the private key privateKeyToAddress(string $privateKeyHex)
  • Check balances balance(Address $address)
  • Transaction transfer (offline signature) transfer(string $from, string $to, float $amount)
  • Query the latest block blockNumber()
  • Query information according to the blockchain blockByNumber(int $blockID)
  • *Query information based on transaction hash transactionReceipt(string $txHash)

Quick Start

Install

composer require fenguoz/tron-php

Interface

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();

Plan

  • Support TRC10
  • Smart Contract

Package

🌟🌟

Stargazers over time

Cooperate

Contact

  • WX:18589058898
  • QQ:996666016