Socket
Book a DemoInstallSign in
Socket

tron_http

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tron_http

0.1.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

TronHttp Ruby

A simple interface to the Tron Network HTTP API.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add tron_http

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install tron_http

Usage

All endpoint declarations are defined in lib/data/tron.yml and get defined when the module is loaded using the TronHTTP::Config.scaffold method.

Network methodsare created automatically for Mainnet, Shashta, Tronex, and Nile.

TronHttp.mainnet.get_transaction_by_id value: 'TX_ID'
TronHttp.tronex.get_transaction_by_id value: 'TX_ID'
TronHttp.shasta.get_transaction_by_id value: 'TX_ID'
TronHttp.nile.get_transaction_by_id value: 'TX_ID'

Each instance will use its relevant host when making requests. Create a new instance of any network like so:

# When no network is specified, defaults to 'shasta'
mainnet_client = TronHttp::Client.new 'mainnet'

Every endpoint listed under endpoints: in the lib/data/tron.yml file is callable on a client instance.

mainnet_client.get_transaction_by_id value: 'tx_id'
=> {}

Ever method requires parameters to be passed as a hash. The passed hash gets stringified and send directly to the relevant endpoint. This makes the interface 1-to-1 with parameters in the API reference.

# BAD
mainnet_client.get_transaction_by_id 'bc1dddbf80346c1f67539f2e878170b9324128988dc5ec0fb717ed50135a1a8c'

# GOOD
mainnet_client.get_transaction_by_id value: 'bc1dddbf80346c1f67539f2e878170b9324128988dc5ec0fb717ed50135a1a8c'

API Reference

Each entry in the data/tron.yml file specifies all parameters required to make requests to a TRON network.

endpoints:
  #
  # https://developers.tron.network/reference/gettransactioninfobyid-1
  get_transaction_info_by_id:
    path: /walletsolidity/gettransactioninfobyid
    method: post
    variables:
      value: string!
  #
  # https://developers.tron.network/reference/gettransactioninfobyblocknum-1
  get_transaction_by_block_num:
    path: /walletsolidity/gettransactioninfobyblocknum
    method: post
    variables:
      value: int32
  #
  # List goes on...

Any variable with a '!' mark suffixed to it's value is required. All other variables are optional.

To learn more about each method, visit the documentation link included above each methods YAML entry.

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sebscholl/tron-http. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Tron::Http project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 22 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.