===================
TRON API for Python
===================
A Python API for interacting with the Tron (TRX)
.. image:: https://img.shields.io/pypi/v/tronapi.svg
:target: https://pypi.python.org/pypi/tronapi
.. image:: https://img.shields.io/pypi/pyversions/tronapi.svg
:target: https://pypi.python.org/pypi/tronapi
.. image:: https://api.travis-ci.com/iexbase/tron-api-python.svg?branch=master
:target: https://travis-ci.com/iexbase/tron-api-python
.. image:: https://img.shields.io/github/issues/iexbase/tron-api-python.svg
:target: https://github.com/iexbase/tron-api-python/issues
.. image:: https://img.shields.io/github/issues-pr/iexbase/tron-api-python.svg
:target: https://github.com/iexbase/tron-api-python/pulls
.. image:: https://api.codacy.com/project/badge/Grade/8a5ae1e1cc834869b1094ea3b0d24f78
:alt: Codacy Badge
:target: https://app.codacy.com/app/serderovsh/tron-api-python?utm_source=github.com&utm_medium=referral&utm_content=iexbase/tron-api-python&utm_campaign=Badge_Grade_Dashboard
------------
**A Command-Line Interface framework**
You can install it in a system-wide location via pip:
.. code-block:: bash
sudo pip3 install tronapi-JCO
Or install it locally using `virtualenv <https://github.com/pypa/virtualenv>`__:
.. code-block:: bash
virtualenv -p /usr/bin/python3 ~/tronapi
source ~/tronapi/bin/activate
pip3 install tronapi
------------
Usage
=====
Specify the API endpoints:
Smart Contract
--------------
.. code-block:: python
from tronapi import Tron
from solc import compile_source
full_node = 'https://api.trongrid.io'
solidity_node = 'https://api.trongrid.io'
event_server = 'https://api.trongrid.io'
tron = Tron(full_node=full_node,
solidity_node=solidity_node,
event_server=event_server)
# or default (tron = Tron())
# Solidity source code
contract_source_code = '''
pragma solidity ^0.4.25;
contract Hello {
string public message;
function Hello(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {
message = newMessage;
}
}
'''
compiled_sol = compile_source(contract_source_code)
contract_interface = compiled_sol['<stdin>:Hello']
hello = tron.trx.contract(
abi=contract_interface['abi'],
bytecode=contract_interface['bin']
)
# Submit the transaction that deploys the contract
tx = hello.deploy(
fee_limit=10**9,
call_value=0,
consume_user_resource_percent=1
)
..
Base Example
------------
.. code-block:: python
from tronapi import Tron
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")
logger = logging.getLogger()
full_node = 'https://api.trongrid.io'
solidity_node = 'https://api.trongrid.io'
event_server = 'https://api.trongrid.io'
tron = Tron(full_node=full_node,
solidity_node=solidity_node,
event_server=event_server)
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))
logger.debug('-----------')
transaction = tron.trx.get_transaction('757a14cef293c69b1cf9b9d3d19c2e40a330c640b05c6ffa4d54609a9628758c')
logger.debug('Transaction: ')
logger.debug('- Hash: ' + transaction['txID'])
logger.debug('- Transaction: ' + json.dumps(transaction, indent=2))
logger.debug('-----------')
# 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 <https://github.com/iexbase/tron-api-python/tree/master/examples>`__.
Documentation
=============
Documentation is available at `docs <https://tronapi-for-python.readthedocs.io/en/latest/>`__.
Donations
=============
TRON: TRWBqiqoFZysoAeyR1J35ibuyc8EvhUAoY
Raw data
{
"_id": null,
"home_page": "https://github.com/RastinS/tron-api-JCO",
"name": "tronapi-JCO",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6,<4",
"maintainer_email": "",
"keywords": "tron tron-api tron-api-python iexbase",
"author": "Rustin Soraki",
"author_email": "rustin.souraki@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a9/8b/b4fbc26a5f9cec1d101cd3f6385ac4dd2734b31cf4f0952623d4e75c489e/tronapi-JCO-3.2.3.tar.gz",
"platform": null,
"description": "===================\nTRON API for Python\n===================\n\nA Python API for interacting with the Tron (TRX)\n\n.. image:: https://img.shields.io/pypi/v/tronapi.svg\n :target: https://pypi.python.org/pypi/tronapi\n\n.. image:: https://img.shields.io/pypi/pyversions/tronapi.svg\n :target: https://pypi.python.org/pypi/tronapi\n\n.. image:: https://api.travis-ci.com/iexbase/tron-api-python.svg?branch=master\n :target: https://travis-ci.com/iexbase/tron-api-python\n \n.. image:: https://img.shields.io/github/issues/iexbase/tron-api-python.svg\n :target: https://github.com/iexbase/tron-api-python/issues\n \n.. image:: https://img.shields.io/github/issues-pr/iexbase/tron-api-python.svg\n :target: https://github.com/iexbase/tron-api-python/pulls\n\n.. image:: https://api.codacy.com/project/badge/Grade/8a5ae1e1cc834869b1094ea3b0d24f78\n :alt: Codacy Badge\n :target: https://app.codacy.com/app/serderovsh/tron-api-python?utm_source=github.com&utm_medium=referral&utm_content=iexbase/tron-api-python&utm_campaign=Badge_Grade_Dashboard\n \n\n------------\n\n**A Command-Line Interface framework**\n\nYou can install it in a system-wide location via pip:\n\n.. code-block:: bash\n\n sudo pip3 install tronapi-JCO\n\nOr install it locally using `virtualenv <https://github.com/pypa/virtualenv>`__:\n\n.. code-block:: bash\n\n virtualenv -p /usr/bin/python3 ~/tronapi\n source ~/tronapi/bin/activate\n pip3 install tronapi\n\n------------\n\nUsage\n=====\nSpecify the API endpoints:\n\n\nSmart Contract\n--------------\n\n.. code-block:: python\n\n from tronapi import Tron\n from solc import compile_source\n\n full_node = 'https://api.trongrid.io'\n solidity_node = 'https://api.trongrid.io'\n event_server = 'https://api.trongrid.io'\n\n tron = Tron(full_node=full_node,\n solidity_node=solidity_node,\n event_server=event_server)\n\n # or default (tron = Tron())\n\n\n # Solidity source code\n contract_source_code = '''\n pragma solidity ^0.4.25;\n\n contract Hello {\n string public message;\n\n function Hello(string initialMessage) public {\n message = initialMessage;\n }\n\n function setMessage(string newMessage) public {\n message = newMessage;\n }\n }\n\n '''\n\n compiled_sol = compile_source(contract_source_code)\n contract_interface = compiled_sol['<stdin>:Hello']\n\n hello = tron.trx.contract(\n abi=contract_interface['abi'],\n bytecode=contract_interface['bin']\n )\n\n # Submit the transaction that deploys the contract\n tx = hello.deploy(\n fee_limit=10**9,\n call_value=0,\n consume_user_resource_percent=1\n )\n\n..\n\nBase Example\n------------\n\n.. code-block:: python\n \n from tronapi import Tron\n logging.basicConfig(level=logging.DEBUG, format=\"%(asctime)s - %(levelname)s - %(message)s\")\n logger = logging.getLogger()\n\n full_node = 'https://api.trongrid.io'\n solidity_node = 'https://api.trongrid.io'\n event_server = 'https://api.trongrid.io'\n\n tron = Tron(full_node=full_node,\n solidity_node=solidity_node,\n event_server=event_server)\n\n account = tron.create_account\n is_valid = bool(tron.trx.is_address(account.address.hex))\n\n logger.debug('Generated account: ')\n logger.debug('- Private Key: ' + account.private_key)\n logger.debug('- Public Key: ' + account.public_key)\n logger.debug('- Address: ')\n logger.debug('-- Base58: ' + account.address.base58)\n logger.debug('-- Hex: ' + account.address.hex)\n logger.debug('-- isValid: ' + str(is_valid))\n logger.debug('-----------')\n \n transaction = tron.trx.get_transaction('757a14cef293c69b1cf9b9d3d19c2e40a330c640b05c6ffa4d54609a9628758c')\n\n logger.debug('Transaction: ')\n logger.debug('- Hash: ' + transaction['txID'])\n logger.debug('- Transaction: ' + json.dumps(transaction, indent=2))\n logger.debug('-----------')\n \n # Events\n event_result = tron.trx.get_event_result('TGEJj8eus46QMHPgWQe1FJ2ymBXRm96fn1', 0, 'Notify')\n\n logger.debug('Event result:')\n logger.debug('Contract Address: TGEJj8eus46QMHPgWQe1FJ2ymBXRm96fn1')\n logger.debug('Event Name: Notify')\n logger.debug('Block Number: 32162')\n logger.debug('- Events: ' + json.dumps(event_result, indent=2))\n\nMore samples and snippets are available at `examples <https://github.com/iexbase/tron-api-python/tree/master/examples>`__.\n\nDocumentation\n=============\n\nDocumentation is available at `docs <https://tronapi-for-python.readthedocs.io/en/latest/>`__.\n\n\nDonations\n=============\n\nTRON: TRWBqiqoFZysoAeyR1J35ibuyc8EvhUAoY\n\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A Python API for interacting with Tron (Forked from tronapi)",
"version": "3.2.3",
"project_urls": {
"Homepage": "https://github.com/RastinS/tron-api-JCO"
},
"split_keywords": [
"tron",
"tron-api",
"tron-api-python",
"iexbase"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d394c43f25a1ed6124baa1ab70841ead8611056939234e9dd4a6e12e6e2d61e9",
"md5": "8cda40e152f5f518047c0561a492b7fa",
"sha256": "809cbe97301e1b65589d9919f95869e6c3b88752c99175de18938fb2cd95a7f2"
},
"downloads": -1,
"filename": "tronapi_JCO-3.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8cda40e152f5f518047c0561a492b7fa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6,<4",
"size": 52385,
"upload_time": "2023-08-12T16:14:18",
"upload_time_iso_8601": "2023-08-12T16:14:18.935688Z",
"url": "https://files.pythonhosted.org/packages/d3/94/c43f25a1ed6124baa1ab70841ead8611056939234e9dd4a6e12e6e2d61e9/tronapi_JCO-3.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a98bb4fbc26a5f9cec1d101cd3f6385ac4dd2734b31cf4f0952623d4e75c489e",
"md5": "380264bbd1b93046c9c74e9d4e068c4f",
"sha256": "cf966f56b613490ac2fbe364fd1fbacbf6a4cf6c43a4810956fbd1fb24e56d89"
},
"downloads": -1,
"filename": "tronapi-JCO-3.2.3.tar.gz",
"has_sig": false,
"md5_digest": "380264bbd1b93046c9c74e9d4e068c4f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6,<4",
"size": 45762,
"upload_time": "2023-08-12T16:14:21",
"upload_time_iso_8601": "2023-08-12T16:14:21.137847Z",
"url": "https://files.pythonhosted.org/packages/a9/8b/b4fbc26a5f9cec1d101cd3f6385ac4dd2734b31cf4f0952623d4e75c489e/tronapi-JCO-3.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-12 16:14:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "RastinS",
"github_project": "tron-api-JCO",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"lcname": "tronapi-jco"
}