Tronpy is a Python library designed for interacting with the TRON blockchain. It provides a convenient interface for developers to work with TRON's features and functionalities.
To use Tronpy, you need to install it via pip:
pip install tronpy
Some of the key features of Tronpy include:
Here's a basic example of using Tronpy to send TRX:
from tronpy import Tron from tronpy.keys import PrivateKey # Initialize Tron client for the mainnet or testnet client = Tron() # Define sender and recipient addresses sender_address = 'T...your_sender_address' recipient_address = 'T...recipient_address' # Define the amount to transfer (in sun, where 1 TRX = 1,000,000 sun) amount = 1_000_000 # 1 TRX in sun # Define the sender's private key sender_private_key = PrivateKey(bytes.fromhex('your_private_key_here')) # Create, sign, and broadcast the transaction with a memo txn = ( client.trx.transfer(sender_address, recipient_address, amount) .memo("test memo") .build() .sign(sender_private_key) .broadcast() ) # Print transaction result print(txn)