Home  >  Article  >  Backend Development  >  PHP calls to realize wave field interaction [supports TRX/TRC20]

PHP calls to realize wave field interaction [supports TRX/TRC20]

藏色散人
藏色散人forward
2021-04-20 09:36:546069browse

tron-php development kit is suitable for quickly accessing TRX and TRC20 digital assets for PHP applications. It supports application scenarios using its own Tron blockchain nodes and also supports services based on Tron’s official public API. lightweight deployment scenarios.

[Recommended learning: PHP video tutorial]

tron-php Github address: https://github.com/Fenguoz/tron-php

Supported methods

  • Generate addressgenerateAddress()
  • Validate addressvalidateAddress(Address $address)
  • Get the address based on the private keyprivateKeyToAddress(string $privateKeyHex)
  • Query balancebalance(Address $address)
  • Transaction transfer (Offline signature) transfer(Address $from, Address $to, float $amount)
  • Query the latest blockblockNumber()
  • According to Blockchain query informationblockByNumber(int $blockID)
  • Query information based on transaction hashtransactionReceipt(string $txHash)

Quick Start

Installation

composer require fenguoz/tron-php

Interface call

use GuzzleHttp\Client;

$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, $this->config);
$addressData = $trc20Wallet->generateAddress();

The above is the detailed content of PHP calls to realize wave field interaction [supports TRX/TRC20]. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete