{"id":22479,"library":"tronpy","title":"Tronpy","description":"Tronpy is a Python client library for interacting with the TRON blockchain. It supports TRON's full node API, TRON Grid API, staking, smart contracts, and transaction building. Current version is 0.6.2, compatible with Python >=3.9. Release cadence is roughly every 3-6 months with feature updates and Python version support bumps.","status":"active","version":"0.6.2","language":"python","source_language":"en","source_url":"https://github.com/andelf/tronpy","tags":["blockchain","tron","web3","cryptocurrency"],"install":[{"cmd":"pip install tronpy","lang":"bash","label":"Install from PyPI"},{"cmd":"pip install tronpy[offline]","lang":"bash","label":"Install with offline transaction support"}],"dependencies":[{"reason":"Cryptography for secp256k1 curves (replaced pure-python ecdsa in v0.3.0)","package":"coincurve","optional":false},{"reason":"HTTP client for API calls","package":"httpx","optional":false},{"reason":"Used for key generation and signing","package":"cryptography","optional":false}],"imports":[{"note":"Tron is exposed at package level; submodule import may break.","wrong":"from tronpy.tron import Tron","symbol":"Tron","correct":"from tronpy import Tron"},{"note":"Module is 'keys' (plural).","wrong":"from tronpy.key import PrivateKey","symbol":"PrivateKey","correct":"from tronpy.keys import PrivateKey"},{"note":"","wrong":"","symbol":"Contract","correct":"from tronpy.contract import Contract"}],"quickstart":{"code":"from tronpy import Tron\nfrom tronpy.providers import HTTPProvider\n\nclient = Tron(provider=HTTPProvider(api_key=os.environ.get('TRONGRID_API_KEY', '')))\n# Get latest block number\nblock = client.get_latest_block_number()\nprint(f\"Latest block: {block}\")","lang":"python","description":"Initialize a Tron client with HTTPProvider (optionally using TRON Grid API key) and fetch latest block number."},"warnings":[{"fix":"Migrate to stake V2 API: use `client.stake_v2` methods like `freeze_balance_v2` and `unfreeze_balance_v2`.","message":"In v0.4.0, stake V1 APIs were removed in favor of stake V2. Old stake methods (freezeBalance, unfreezeBalance) no longer work. Use stake_v2 methods instead.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Upgrade Python to 3.9 or higher.","message":"Support for Python 3.8 was dropped in v0.6.0. The package now requires Python >=3.9.","severity":"deprecated","affected_versions":">=0.6.0"},{"fix":"Ensure you include `ref_block_id` from a recent block when building offline transactions.","message":"When using offline transaction creation (v0.6.0+), you must provide `ref_block_id` and `offline=True` to `build()`. Forgetting `ref_block_id` will cause transaction rejection on the network.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Upgrade to 0.6.0+ for `get_energy` method.","message":"The `get_energy` method was added in v0.6.0. In earlier versions, energy estimation required a different approach (e.g., using `trigger_constant_contract`).","severity":"gotcha","affected_versions":"<0.6.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from tronpy import Tron` (correct). Ensure you have installed the latest version.","cause":"Incorrect import path; Tron is not directly under tronpy due to import errors in older versions or when using a different structure.","error":"AttributeError: module 'tronpy' has no attribute 'Tron'"},{"fix":"Upgrade tronpy to version 0.3.0 or later. Then `from tronpy.providers import HTTPProvider`.","cause":"The provider module was renamed or restructured in earlier versions (before 0.3.0).","error":"ImportError: cannot import name 'HTTPProvider' from 'tronpy.providers'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}