Name | tronpy JSON |
Version |
0.6.0
JSON |
| download |
home_page | None |
Summary | TRON Python client library |
upload_time | 2025-07-16 19:27:12 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
api
blockchain
tron
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# tronpy
[](https://pypi.org/project/tronpy/)
[](https://dl.circleci.com/status-badge/redirect/gh/andelf/tronpy/tree/master)
TRON Python Client Library. [Documentation](https://tronpy.readthedocs.io/en/latest/index.html)
> Note: in case you want to use cryptocurrency functions in an universal way or e.g. reliably calculate transaction fees for BTC, ETH, Tron and many others, check out the [Bitcart project](https://bitcart.ai)
## How to use
```python
from tronpy import Tron
from tronpy.keys import PrivateKey
client = Tron(network='nile')
# Private key of TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3
priv_key = PrivateKey(bytes.fromhex("8888888888888888888888888888888888888888888888888888888888888888"))
txn = (
client.trx.transfer("TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3", "TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA", 1_000)
.memo("test memo")
.build()
.inspect()
.sign(priv_key)
.broadcast()
)
print(txn)
# > {'result': True, 'txid': '5182b96bc0d74f416d6ba8e22380e5920d8627f8fb5ef5a6a11d4df030459132'}
print(txn.wait())
# > {'id': '5182b96bc0d74f416d6ba8e22380e5920d8627f8fb5ef5a6a11d4df030459132', 'blockNumber': 6415370, 'blockTimeStamp': 1591951155000, 'contractResult': [''], 'receipt': {'net_usage': 283}}
```
### Async Client
```python
import asyncio
from tronpy import AsyncTron
from tronpy.keys import PrivateKey
# private key of TMisHYBVvFHwKXHPYTqo8DhrRPTbWeAM6z
priv_key = PrivateKey(bytes.fromhex("8888888888888888888888888888888888888888888888888888888888888888"))
async def transfer():
async with AsyncTron(network='nile') as client:
print(client)
txb = (
client.trx.transfer("TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3", "TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA", 1_000)
.memo("test memo")
.fee_limit(100_000_000)
)
txn = await txb.build()
print(txn)
txn_ret = await txn.sign(priv_key).broadcast()
print(txn_ret)
# > {'result': True, 'txid': 'edc2a625752b9c71fdd0d68117802860c6adb1a45c19fd631a41757fa334d72b'}
print(await txn_ret.wait())
# > {'id': 'edc2a625752b9c71fdd0d68117802860c6adb1a45c19fd631a41757fa334d72b', 'blockNumber': 10163821, 'blockTimeStamp': 1603368072000, 'contractResult': [''], 'receipt': {'net_usage': 283}}
if __name__ == '__main__':
asyncio.run(transfer())
```
Or close async client manually:
```python
from httpx import AsyncClient, Timeout
from tronpy.providers.async_http import AsyncHTTPProvider
from tronpy.defaults import CONF_NILE
async def transfer():
_http_client = AsyncClient(limits=Limits(max_connections=100, max_keepalive_connections=20),
timeout=Timeout(timeout=10, connect=5, read=5))
provider = AsyncHTTPProvider(CONF_NILE, client=_http_client)
client = AsyncTron(provider=provider)
print(client)
priv_key = PrivateKey(bytes.fromhex("8888888888888888888888888888888888888888888888888888888888888888"))
txb = (
client.trx.transfer("TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3", "TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA", 1_000)
.memo("test memo")
.fee_limit(100_000_000)
)
txn = await txb.build()
print(txn)
txn_ret = await txn.sign(priv_key).broadcast()
print(txn_ret)
print(await txn_ret.wait())
await client.close()
if __name__ == '__main__':
asyncio.run(transfer())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "tronpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "api, blockchain, tron",
"author": null,
"author_email": "andelf <andelf@gmail.com>, MrNaif2018 <chuff184@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8a/6c/79291a951cda9bcb25b6c0d733199b9da0a54883a150eb3e8df7282513f3/tronpy-0.6.0.tar.gz",
"platform": null,
"description": "# tronpy\n\n[](https://pypi.org/project/tronpy/)\n[](https://dl.circleci.com/status-badge/redirect/gh/andelf/tronpy/tree/master)\n\nTRON Python Client Library. [Documentation](https://tronpy.readthedocs.io/en/latest/index.html)\n\n> Note: in case you want to use cryptocurrency functions in an universal way or e.g. reliably calculate transaction fees for BTC, ETH, Tron and many others, check out the [Bitcart project](https://bitcart.ai)\n\n## How to use\n\n```python\nfrom tronpy import Tron\nfrom tronpy.keys import PrivateKey\n\nclient = Tron(network='nile')\n# Private key of TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3\npriv_key = PrivateKey(bytes.fromhex(\"8888888888888888888888888888888888888888888888888888888888888888\"))\n\ntxn = (\n client.trx.transfer(\"TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3\", \"TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA\", 1_000)\n .memo(\"test memo\")\n .build()\n .inspect()\n .sign(priv_key)\n .broadcast()\n)\n\nprint(txn)\n# > {'result': True, 'txid': '5182b96bc0d74f416d6ba8e22380e5920d8627f8fb5ef5a6a11d4df030459132'}\nprint(txn.wait())\n# > {'id': '5182b96bc0d74f416d6ba8e22380e5920d8627f8fb5ef5a6a11d4df030459132', 'blockNumber': 6415370, 'blockTimeStamp': 1591951155000, 'contractResult': [''], 'receipt': {'net_usage': 283}}\n```\n\n### Async Client\n\n```python\nimport asyncio\n\nfrom tronpy import AsyncTron\nfrom tronpy.keys import PrivateKey\n\n# private key of TMisHYBVvFHwKXHPYTqo8DhrRPTbWeAM6z\npriv_key = PrivateKey(bytes.fromhex(\"8888888888888888888888888888888888888888888888888888888888888888\"))\n\nasync def transfer():\n async with AsyncTron(network='nile') as client:\n print(client)\n\n txb = (\n client.trx.transfer(\"TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3\", \"TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA\", 1_000)\n .memo(\"test memo\")\n .fee_limit(100_000_000)\n )\n txn = await txb.build()\n print(txn)\n txn_ret = await txn.sign(priv_key).broadcast()\n print(txn_ret)\n # > {'result': True, 'txid': 'edc2a625752b9c71fdd0d68117802860c6adb1a45c19fd631a41757fa334d72b'}\n print(await txn_ret.wait())\n # > {'id': 'edc2a625752b9c71fdd0d68117802860c6adb1a45c19fd631a41757fa334d72b', 'blockNumber': 10163821, 'blockTimeStamp': 1603368072000, 'contractResult': [''], 'receipt': {'net_usage': 283}}\n\nif __name__ == '__main__':\n asyncio.run(transfer())\n```\n\nOr close async client manually:\n\n```python\nfrom httpx import AsyncClient, Timeout\nfrom tronpy.providers.async_http import AsyncHTTPProvider\nfrom tronpy.defaults import CONF_NILE\n\n\nasync def transfer():\n _http_client = AsyncClient(limits=Limits(max_connections=100, max_keepalive_connections=20),\n timeout=Timeout(timeout=10, connect=5, read=5))\n provider = AsyncHTTPProvider(CONF_NILE, client=_http_client)\n client = AsyncTron(provider=provider)\n print(client)\n\n priv_key = PrivateKey(bytes.fromhex(\"8888888888888888888888888888888888888888888888888888888888888888\"))\n txb = (\n client.trx.transfer(\"TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3\", \"TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA\", 1_000)\n .memo(\"test memo\")\n .fee_limit(100_000_000)\n )\n txn = await txb.build()\n print(txn)\n txn_ret = await txn.sign(priv_key).broadcast()\n\n print(txn_ret)\n print(await txn_ret.wait())\n await client.close()\n\nif __name__ == '__main__':\n asyncio.run(transfer())\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "TRON Python client library",
"version": "0.6.0",
"project_urls": {
"Documentation": "https://tronpy.readthedocs.io",
"Homepage": "https://github.com/andelf/tronpy",
"Repository": "https://github.com/andelf/tronpy"
},
"split_keywords": [
"api",
" blockchain",
" tron"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6b5fe5e2a47f8f036dca845f235b5e26781fe242898760a61c4c1bc022c8fe36",
"md5": "eb39aa603a4dd730cfd4ccf643bbd3ba",
"sha256": "1daf3cd050787249f64f00f5fcdb5def939488ad2a40cb02a8cc0b973cefc6be"
},
"downloads": -1,
"filename": "tronpy-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb39aa603a4dd730cfd4ccf643bbd3ba",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 50937,
"upload_time": "2025-07-16T19:27:11",
"upload_time_iso_8601": "2025-07-16T19:27:11.950500Z",
"url": "https://files.pythonhosted.org/packages/6b/5f/e5e2a47f8f036dca845f235b5e26781fe242898760a61c4c1bc022c8fe36/tronpy-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8a6c79291a951cda9bcb25b6c0d733199b9da0a54883a150eb3e8df7282513f3",
"md5": "567564078a1ce4b05bc2cf88a0998510",
"sha256": "c07d528517c2a41411a144938da7db3d5fc5cce0989c7cb91ff8ac82a74a0847"
},
"downloads": -1,
"filename": "tronpy-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "567564078a1ce4b05bc2cf88a0998510",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 149977,
"upload_time": "2025-07-16T19:27:12",
"upload_time_iso_8601": "2025-07-16T19:27:12.855562Z",
"url": "https://files.pythonhosted.org/packages/8a/6c/79291a951cda9bcb25b6c0d733199b9da0a54883a150eb3e8df7282513f3/tronpy-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-16 19:27:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "andelf",
"github_project": "tronpy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "tronpy"
}