andelf / tronpy

TRON Python Client Library.
MIT License
204 stars 96 forks source link

How to use `PrivateKey.fromhex()`? #96

Closed krau5 closed 1 year ago

krau5 commented 1 year ago

There is no exact explanation either in the documentation or in the tronpy repo with an example of PrivateKey.fromhex() usage and which data should I put inside. I would be glad if someone gives me an explanation of this method, I may even contribute to the docs, so that no one will face this problem again. If you have any questions, or my question seems unclear - you're welcome to ask the details

MrNaif2018 commented 1 year ago

Hi! I mean, the fromhex method is to get the privatekey object created from privatekey string like in all blockchains (I think it starts with 0x, don't remember for sure). Because default Privatekey constructor accepts bytes only, so this factory method is needed

krau5 commented 1 year ago

Hi, @MrNaif2018 👋🏻 If so, I have another question. How can I get a PrivateKey? I have a mnemonics, with mnemonics I can get like... everything? I have address and all the other fancy data, but I cannot find an information of how can I actually get the private key for the exact address to sign the transactions later

MrNaif2018 commented 1 year ago

eth-account, see https://github.com/bitcart/bitcart/blob/master/daemons/trx.py#L172

krau5 commented 1 year ago

Thanks, I'll have a look! Please, don't close the issue right now, I'll close it by myself when the problem will be solved