Mistelo
Mistelo

Reputation: 136

How to find public address through private key on TRON

How can I find user public address from his private key ? Already I found a way to convert public to hex Address also private to hex and reverse but get stuck in this one !

Upvotes: 2

Views: 5466

Answers (3)

dezhi
dezhi

Reputation: 909

If you are using python, the official tronpy document doesn't mentioned this. However, you can find the answer by yourself.

Open ipython from terminal, create a key object from a random key, input the key variable name and press tab twice, you will see all the attributes and functions of the object.

import tronpy


my_random_key = tronpy.keys.PrivateKey.random()
my_key = tronpy.keys.PrivateKey.fromhex(my_random_key)
my_key.public_key.to_base58check_address()

Upvotes: 1

joeytwiddle
joeytwiddle

Reputation: 31285

Using TronWeb, you can call this function:

const address = tronWeb.address.fromPrivateKey(newAccount.privateKey);

That code comes from one of TronWeb's tests

Upvotes: 4

sajjad hajizadeh
sajjad hajizadeh

Reputation: 11

for bitcoin you need use this package to find public key => dart_wif

print('hex :::::: ${HEX.encode(index.privateKey!)}');

WIF decoded = WIF(version: 128, privateKey: index.privateKey!, compressed: true);

String key = wif.encode(decoded);
print(key);

Upvotes: 0

Related Questions