Get transaction hash from raw transaction in aptos network

146 views Asked by At

I need to get transaction hash or id before broadcasting a signed transaction. I looked around for a library or package and couldn't find one. After looking around in aptos-core source code, found these comments:

    /// To create a transaction hash by yourself, do the following:
    ///   1. Hash message bytes: "RawTransaction" bytes + BCS bytes of [Transaction](https://aptos-labs.github.io/aptos-core/aptos_types/transaction/enum.Transaction.html).
    ///   2. Apply hash algorithm `SHA3-256` to the hash message bytes.
    ///   3. Hex-encode the hash bytes with `0x` prefix.
    // TODO: Include a link to an example of how to do this ^

Srouce (https://github.com/aptos-labs/aptos-core/blob/main/api/src/transactions.rs#L186)

And I have not idea of how to do step 1. Any help would be appreciated.

I tried to do the instructions provided in "https://aptos-labs.github.io/aptos-core/aptos_types/transaction/enum.Transaction.html" but this link is not available or private.

0

There are 0 answers