Correct balance and transfer amount in TRX

The code has been updated to display the account balance and to ask for the transfer amount in TRX. The transfer method has also been modified to facilitate transactions in multiples of 1,000,000.
This commit is contained in:
Benny 2023-12-10 21:29:35 +01:00
parent 25e3e724d1
commit bbc357e7b5
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481

View file

@ -12,9 +12,10 @@ mnemonic = "web horse smile ramp olive slush blue property world physical donkey
client = Tron(network="nile")
from_ = client.generate_address_from_mnemonic(mnemonic, account_path="m/44'/195'/0'/0/0")["base58check_address"]
print("my addr: ", from_)
balance = client.get_account_balance(from_)
print("my addr: ", from_, "balance: ", balance)
to = input("to: ")
amount = int(input("amount: 1_000_000\n"))
amount = int(input("amount in TRX: "))
def mnemonic_to_private_key():
@ -23,6 +24,6 @@ def mnemonic_to_private_key():
return PrivateKey(private_key)
t = client.trx.transfer(from_, to, amount).build().inspect().sign(mnemonic_to_private_key()).broadcast()
t = client.trx.transfer(from_, to, amount * 1_000_000).build().sign(mnemonic_to_private_key()).broadcast()
print(t.wait())