Google Protocol Buffers (GPB)


ProtoBuf is a flexible and efficient language-independent structured data representation method that can be used to represent communication protocols and data storage. Compared to XML, ProtoBuF is smaller, faster and simpler. You can use the ProtoBuf compiler to generate source code for specific languages (such as C++, Java, Python, etc., ProtoBuf currently supports mainstream programming languages) for serialization and deserialization.

Tron applies GPB-message standard to communicate with tron network, such as generate signed raw tx with transfer contract and broadcast to network.


Steps to install Protocol Buffer Compiler (protoc)

  1. Download protoc from release repository.
    #create a directory to house protoc
    $ mkdir protoc
    
    $ cd protoc
    
    #btcschools.net applied protoc v3.14.0 with linux os and x86_64 architeture
    $ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip
    
  2. Extract zip file
    $ unzip protoc-3.14.0-linux-x86_64.zip
    
  3. Tell protoc version
    		
    $ cd bin
    
    $ ./protoc --version
    # this will output libprotoc 3.14.0
    

Steps to download tron's message scheme

  1. Download wallet-CLI
    $ git clone https://github.com/tronprotocol/wallet-cli
    # a wallet-cli folder will be created automatically
    
  2. Check tron's message scheme
    		
    $ ls wallet-cli/src/main/protos/core
    #You will see many different raw message
    

Build PHP scripts from compiling tron's message scheme

  1. Compile all required *.proto and output to desired path. Absolute path here applied for ease of maintenance.
    		
    #compile Discover.proto
    $ /home/btcschools/protoc/bin/protoc --proto_path='/home/btcschools/wallet-cli/src/main/protos' --php_out='/home/btcschools/public_html/tron/protobuf/core' core/Discover.proto
    
    #compile Tron.proto
    $ /home/btcschools/protoc/bin/protoc --proto_path='/home/btcschools/wallet-cli/src/main/protos' --php_out='/home/btcschools/public_html/tron/protobuf/core' core/Tron.proto
    
    #compile TronInventoryItems.proto
    $ /home/btcschools/protoc/bin/protoc --proto_path='/home/btcschools/wallet-cli/src/main/protos' --php_out='/home/btcschools/public_html/tron/protobuf/core' core/TronInventoryItems.proto
    
    #compile all system contract's proto files
    $ /home/btcschools/protoc/bin/protoc --proto_path='/home/btcschools/wallet-cli/src/main/protos' --php_out='/home/btcschools/public_html/tron/protobuf/core/contract' core/contract/*.proto
    








Tutorials
About Us
Contents have been open source in GITHUB. Please give me a ⭐ if you found this helpful :)
Community
Problem? Raise me a new issue.
Support Us
Buy me a coffee. so i can spend more nights for this :)

BTCSCHOOLS would like to present you with more pratical but little theory throughout our tutorials. Pages' content are constantly keep reviewed to avoid mistakes, but we cannot warrant correctness of all contents. While using this site, you agree to accept our terms of use, cookie & privacy policy. Copyright 2019 by BTCSCHOOLS. All Rights Reserved.