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)

[![Software License](https://img.shields.io/badge/license-Apache-brightgreen.svg?style=flat-square)](LICENSE)
[![Build Status](https://api.travis-ci.com/iexbase/tron-api-python.svg?branch=master)](https://travis-ci.com/iexbase/tron-api-python)
[![Issues](https://img.shields.io/github/issues/iexbase/tron-api-python.svg)](https://github.com/iexbase/tron-api-python/issues)
[![Pull Requests](https://img.shields.io/github/issues-pr/iexbase/tron-api-python.svg)](https://github.com/iexbase/tron-api-python/pulls)
[![Contributors](https://img.shields.io/github/contributors/iexbase/tron-api-python.svg)](https://github.com/iexbase/tron-api-python/graphs/contributors)

## Install

| Setup | Command | Notes
| :------ | :------------------ | :---------
| install | `pip install tronapi` |


## Basic Usage
Specify the API endpoints:

```python
full_node = HttpProvider('https://api.trongrid.io')
solidity_node = HttpProvider('https://api.trongrid.io')
event_server = HttpProvider('https://api.trongrid.io')
```

The provider above is optional, you can just use a url for the nodes instead, like here:

```python
full_node = 'https://api.trongrid.io'
solidity_node = 'https://api.trongrid.io'
event_server = 'https://api.trongrid.io'
```

Now, instance a Tron class:

```python
private_key = '....'
tron = Tron(full_node,
solidity_node,
event_server,
private_key)
```

**A full example:**

```python
from tronapi.provider import HttpProvider
from tronapi.tron import Tron

full_node = HttpProvider('https://api.trongrid.io')
solidity_node = HttpProvider('https://api.trongrid.io')
event_server = HttpProvider('https://api.trongrid.io')

# optional
private_key = '...'

tron = Tron(full_node,
solidity_node,
event_server,
private_key)


block = tron.get_current_block()
balance = tron.get_balance('TRWBqiqoFZysoAeyR1J35ibuyc8EvhUAoY', True)
```


### Cli
```bash
> python cli.py send from to amount private_key
> python cli.py --generateaddress
> python cli.py --node=customnode --getbalance address
```


## Donations
**Tron(TRX)**: TRWBqiqoFZysoAeyR1J35ibuyc8EvhUAoY

Project details


Download files

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

Source Distribution

tronapi-2.0.2.tar.gz (11.5 kB view details)

Uploaded Source

File details

Details for the file tronapi-2.0.2.tar.gz.

File metadata

  • Download URL: tronapi-2.0.2.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for tronapi-2.0.2.tar.gz
Algorithm Hash digest
SHA256 e443ef740125e68964d20b30eeebe930a9431d66e59bc82b910b481a360901a1
MD5 6e81aa6496cab2a7f03f6a04147eab08
BLAKE2b-256 c50360a74993a8ebb5ce2df87d310276f1ec88552c6155e3139aff435383cb22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page