Download scripts/transfer.py from navpan2/dockerbot: direct link, hf CLI and curl.
- Browser
- Download file 912 Bytes
-
https://huggingface.co/spaces/navpan2/dockerbot/resolve/main/scripts/transfer.py
- Command line
-
hf download hf://spaces/navpan2/dockerbot/scripts/transfer.py
-
curl -L -o transfer.py https://huggingface.co/spaces/navpan2/dockerbot/resolve/main/scripts/transfer.py
912 Bytes
| #!/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"] | |
| balance = client.get_account_balance(from_) | |
| print("my addr: ", from_, "balance: ", balance) | |
| to = input("to: ") | |
| amount = int(input("amount in TRX: ")) | |
| 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) | |
| t = client.trx.transfer(from_, to, amount * 1_000_000).build().sign(mnemonic_to_private_key()).broadcast() | |
| print(t.wait()) | |