Skip to main content

A Python API for interacting with Tron (TRX)

Project description

TRON API for Python
A Python API for interacting with the Tron (TRX)

.. image::

.. image::

.. image::

.. image::

.. image::

.. image::
:alt: Codacy Badge


**A Command-Line Interface framework**

Installation is easy via pip:

.. code-block:: bash

pip3 install tronapi


Specify the API endpoints:

.. code-block:: python

from tronapi.main import Tron

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")
logger = logging.getLogger()

full_node = HttpProvider('')
solidity_node = HttpProvider('')
event_server = HttpProvider('')

tron = Tron(full_node,

account = tron.create_account()
is_valid = bool(tron.trx.is_address(account.address.hex))

logger.debug('Generated account: ')
logger.debug('- Private Key: ' + account.private_key())
logger.debug('- Public Key: ' + account.public_key())
logger.debug('- Address: ')
logger.debug('-- Base58: ' + account.address.base58)
logger.debug('-- Hex: ' + account.address.hex)
logger.debug('-- isValid: ' + str(is_valid))

transaction = tron.trx.get_transaction('757a14cef293c69b1cf9b9d3d19c2e40a330c640b05c6ffa4d54609a9628758c')

logger.debug('Transaction: ')
logger.debug('- Hash: ' + transaction['txID'])
logger.debug('- Transaction: ' + json.dumps(transaction, indent=2))

# Events
event_result = tron.trx.get_event_result('TGEJj8eus46QMHPgWQe1FJ2ymBXRm96fn1', 0, 'Notify')

logger.debug('Event result:')
logger.debug('Contract Address: TGEJj8eus46QMHPgWQe1FJ2ymBXRm96fn1')
logger.debug('Event Name: Notify')
logger.debug('Block Number: 32162')
logger.debug('- Events: ' + json.dumps(event_result, indent=2))

More samples and snippets are available at `examples <>`__.


Documentation is available at `docs <>`__.


TRON: TRWBqiqoFZysoAeyR1J35ibuyc8EvhUAoY

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
tronapi-2.0.5.tar.gz (20.1 kB) Copy SHA256 hash SHA256 Source None Nov 11, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page