Skip to content

Tron Wallet

MMDRZA edited this page Feb 24, 2024 · 1 revision

Tron Wallet From Libit

after install libit package with pip in windows and pip3 in linux can use this library for your project in python .

  • windows pip : pip install --upgrade libit
  • linux pip3 : pip3 install --upgrade libit

Example : Generated Private Key (hex) and Convert to Tron Address , Decimal after that Convert Tron (TRX) Address To Hash and Hex string format.

from libit import tronAddress, tronHash, tronHex, tronDec
import os
# // generate private key random
key = os.urandom(32).hex()
# // private key to tron address
addr = tronAddress(key)
# // private key to decimal format
trondec = tronDec(key)
# // tron address to hash string format
hash_addr = tronHash(addr)
# // tron address to hex string format
hex_Addr = tronHex(addr)
# // print result
print("Private Key:", key)
print("Decimal:", trondec)
print("Tron Address:", addr)
print("Hash Address:", hash_addr)
print("Hex Address:", hex_Addr)

can use from Tron in script and insert class mode : Tron.Wallet

from libit import Tron
import os
# // Tron Wallet Class
trx = Tron.Wallet
# // Generate Private Key HEX format random
key = os.urandom(32).hex()
# // Get Tron Address
tron_address = trx.get_address(key)
print("Tron Address: ", tron_address)
# // Get Decimal
dec = trx.get_decimal(key)
print("Decimal: ", dec)
# // Get Address Hex from Tron Address
tron_address_hex = trx.get_hexAddress(tron_address)
print("Tron Address Hex: ", tron_address_hex)
# // Get Address Hash from Tron Address
tron_address_hash = trx.get_hashAddress(tron_address)
print("Tron Address Hash: ", tron_address_hash)
# // Result
# Tron Address:  TC6Ct33ha2mhWPnpDsZmrNWfURiPFsMRmq
# Decimal:  80419471796607208560368483611858453431640496938884352276627738528793354907629
# Tron Address Hex:  0x17430fede778a451eff57bccf768ddc7a1cc9275
# Tron Address Hash:  4117430fede778a451eff57bccf768ddc7a1cc9275

in python script can just import libit (Example : import os, libit)

import os, libit

# // Private Key Hex Random
key = os.urandom(32).hex()
print(key)
# // Tron Address From Private Key
tron_address = libit.tronAddress(key)
print(tron_address)
# // Tron Hash Address From Address
tron_hash = libit.tronHash(tron_address)
print(tron_hash)
# // Tron Hex Address From Address
tron_hex = libit.tronHex(tron_address)
print(tron_hex)
Clone this wiki locally