2023-12-09 01:56:57 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
# ytdlbot - transfer.py
|
|
|
|
# 2023-12-07 18:21
|
|
|
|
from tronpy import Tron
|
|
|
|
from tronpy.hdwallet import seed_from_mnemonic, key_from_seed
|
|
|
|
from tronpy.keys import PrivateKey
|
|
|
|
|
|
|
|
mnemonic = "web horse smile ramp olive slush blue property world physical donkey pumpkin"
|
|
|
|
|
|
|
|
client = Tron(network="nile")
|
|
|
|
|
|
|
|
from_ = client.generate_address_from_mnemonic(mnemonic, account_path="m/44'/195'/0'/0/0")["base58check_address"]
|
2023-12-11 04:29:35 +08:00
|
|
|
balance = client.get_account_balance(from_)
|
|
|
|
print("my addr: ", from_, "balance: ", balance)
|
2023-12-09 01:56:57 +08:00
|
|
|
to = input("to: ")
|
2023-12-11 04:29:35 +08:00
|
|
|
amount = int(input("amount in TRX: "))
|
2023-12-09 01:56:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
def mnemonic_to_private_key():
|
|
|
|
seed = seed_from_mnemonic(mnemonic, passphrase="")
|
|
|
|
private_key = key_from_seed(seed, account_path="m/44'/195'/0'/0/0")
|
|
|
|
return PrivateKey(private_key)
|
|
|
|
|
|
|
|
|
2023-12-11 04:29:35 +08:00
|
|
|
t = client.trx.transfer(from_, to, amount * 1_000_000).build().sign(mnemonic_to_private_key()).broadcast()
|
2023-12-09 01:56:57 +08:00
|
|
|
|
|
|
|
print(t.wait())
|