Giter Site home page Giter Site logo

elaheh4 / tron-php-wallet-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maxdw/tron-php-wallet-api

0.0 0.0 0.0 34 KB

This is an implementation of the TRON protocol in PHP using GRPC.

License: GNU Lesser General Public License v3.0

Shell 0.80% PHP 99.20%

tron-php-wallet-api's Introduction

PHP TRON Wallet API

This is an implementation of the TRON protocol in PHP using GRPC.

Documentation

If new to protocol buffers or GRPC start with the following documentation:

  1. Google Protocol Buffers documentation
  2. GRPC PHP documentation

Examples

List witnesses
$wallet = new \Protocol\WalletClient('47.91.216.69:50051', [
   'credentials' => Grpc\ChannelCredentials::createInsecure()
]);

$emptyMessage = new \Protocol\EmptyMessage();

/* @var \Protocol\WitnessList $witnesses */
list($witnesses, $options) = $wallet->ListWitnesses($emptyMessage)->wait();

$base58 = new Tuupola\Base58;

/* @var \Protocol\Witness $witness */
foreach ($witnesses->getWitnesses() as $witness) {
    var_dump($base58->encode($witness->getAddress()));
}
Scan the blockchain
$wallet = new \Protocol\WalletClient('47.91.216.69:50051', [
    'credentials' => Grpc\ChannelCredentials::createInsecure()
]);

$n = 15523;
do {
    $numberMessage = new \Protocol\NumberMessage();
    $numberMessage->setNum($n--);
    list($block, $meta) = $wallet->GetBlockByNum($numberMessage)->wait();
    /* @var \Protocol\Block $block */
    $transactions = $block->getTransactions();
} while(!$transactions->count());

var_dump(sprintf('block #%d seems to have %d transactions!', $n, $transactions->count()));

Development

To update PHP files according to the TRON protocol install protoc and run

sudo bash ./genphp.sh

Issues

  • Encoding and crypto utilities
  • Unit tests
  • Proper namespacing of protocol and metadata classes e.g. Tron\Protocol\Account instead of Protocol\Account
  • Add proper @return tags and type hinting (this is a protoc issue? docblocks could be improved to remove the need for inline typehinting)

tron-php-wallet-api's People

Contributors

maxdw 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.