Giter Site home page Giter Site logo

zhouyazun / tron-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fenguoz/tron-php

0.0 0.0 0.0 53 KB

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

License: MIT License

PHP 100.00%

tron-php's Introduction

TRON-PHP

概述

TRON-PHP 目前支持波场的 TRX 和 TRC20 中常用生成地址,发起转账,离线签名等功能。

特点

  1. 一套写法兼容 TRON 网络中 TRX 货币和 TRC 系列所有通证
  2. 接口方法可可灵活增减

支持方法

  • 生成地址 generateAddress()
  • 验证地址 validateAddress(Address $address)
  • 根据私钥得到地址 privateKeyToAddress(string $privateKeyHex)
  • 查询余额 balance(Address $address)
  • 交易转账(离线签名) transfer(Address $from, Address $to, float $amount)
  • 查询最新区块 blockNumber()
  • 根据区块链查询信息 blockByNumber(int $blockID)
  • 根据交易哈希查询信息 transactionReceipt(string $txHash)

快速开始

安装

composer require fenguoz/tron-php

接口调用

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

计划

  • 支持 TRC10
  • 智能合约

扩展包

扩展包名 描述 应用场景
iexbase/tron-api 波场官方文档推荐 PHP 扩展包 波场基础Api

🌟🌟

Stargazers over time

合作

联系方式

  • WX:zgf243944672
  • QQ:243944672

tron-php's People

Contributors

fenguoz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.