CryptoTron

 view release on metacpan or  search on metacpan

lib/CryptoTron/CreateAccount.pm  view on Meta::CPAN

    mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_12)
    # Print the mnemonic to screen.
    print(fmt_str.format("Mnemonic:", mnemonic))
    # Print message to screen.
    print("\n*** Create private key, public key and Tron address using Bip39 and Bip44\n")
    # Generate seed with automatic language detection and empty passphrase.
    seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
    # Create Bip44 Tron object.
    bip44_tron = Bip44.FromSeed(seed_bytes, Bip44Coins.TRON)
    # Create a private key in hex and upper case.
    private_key = bip44_tron.PrivateKey().Raw().ToHex().upper()
    # Create a public key in upper case.
    public_key = str(bip44_tron.PublicKey().RawUncompressed()).upper()
    # Create Base58 address.
    base58_addr = bip44_tron.PublicKey().ToAddress()
    # Create a Hex address in hex and upper case.
    hex_addr = base58.b58decode_check(base58_addr).hex().upper()
    # Print result to screen.
    print(fmt_str.format("Private Key:", private_key))
    print(fmt_str.format("Address (Base58):", base58_addr))
    print(fmt_str.format("Address (Hex): ", hex_addr))
    print(fmt_str.format("Public Key: ", public_key))

def mnemonic():
    # Generate a random mnemonic string of 12 words with default language (English)
    mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_12)
    # Return 12 word mnemonic list.
    return mnemonic



( run in 0.360 second using v1.01-cache-2.11-cpan-a5abf4f5562 )