-
At present, I can get the transaction hash when sending it to the chain, and search it on explorer. Looking forward to your reply |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hi @Wangmmx . Sure you can calculate it before sending. Here is an example in tx = Transaction(...)
tx.update_hash()
# Here tx.hash is updated and contains the tx's hash.
h1 = tx.calculate_hash()
assert h1 == tx.hash Link: https://github.com/HathorNetwork/python-hathorlib/blob/main/hathorlib/base_transaction.py#L375-L389 I just noticed that we don't have such method in our nodejs lib. I'll add it as an issue and discuss about it in our daily meeting tomorrow morning. |
Beta Was this translation helpful? Give feedback.
-
Thank you for replying to me, I do need to use nodejs, but it’s okay, I’ll go see the python lib |
Beta Was this translation helpful? Give feedback.
-
I use the default nonce as 0 to construct the transaction body. How do I get the specific nonce? |
Beta Was this translation helpful? Give feedback.
-
@Wangmmx Just to let you know that @pedroferreira1 is working to add this method to the nodejs lib. It should be reviewed and available tomorrow. Here is the issue so you can follow: HathorNetwork/hathor-wallet-lib#200 |
Beta Was this translation helpful? Give feedback.
-
In order to get the right nonce, you have to mine the transaction. I highly recommend you to use tx-mining-service. Our lib has a full featured client that you easily use. Here is the link: https://github.com/HathorNetwork/hathor-wallet-lib/blob/f901159b3033c3bc2582cf802106947890cb35d2/src/wallet/mineTransaction.ts#L29-L43 Or you can use this facade that also pushes the transaction to the network after it is ready. Here the link: https://github.com/HathorNetwork/hathor-wallet-lib/blob/f901159b3033c3bc2582cf802106947890cb35d2/src/new/sendTransaction.js#L23-L39 |
Beta Was this translation helpful? Give feedback.
-
If you're building a wallet, this README might be useful. We have a full featured class that makes it very easy to build a wallet on top of it. This class is used by all our wallets (macOS, Linux, Windows, iOS, Android) and also by our headless wallet. Link: https://github.com/HathorNetwork/hathor-wallet-lib/tree/master/src/new |
Beta Was this translation helpful? Give feedback.
Hi @Wangmmx . Sure you can calculate it before sending. Here is an example in
python-hathorlib
where I calculate the hash using two different methods:Link: https://github.com/HathorNetwork/python-hathorlib/blob/main/hathorlib/base_transaction.py#L375-L389
I just noticed that we don't have such method in our nodejs lib. I'll add it as an issue and discuss about it in our daily meeting tomorrow morning.