[Ethereum] How to get raw ethereum transaction hash

raw-transactiontransactions

I searched around for an answer to this question, however couldn't find one.
So let's assume we've a raw ethereum transaction and before broadcasting we'd like to know the transaction hash. Is it possible to find out the hash before it's being broadcasted (i.e. via eth_sendRawTransaction RPC method).

For instance for raw transaction hex:

0xf86c258502540be40083035b609482e041e84074fc5f5947d4d27e3c44f824b7a1a187b1a2bc2ec500008078a04a7db627266fa9a4116e3f6b33f5d245db40983234eb356261f36808909d2848a0166fa098a2ce3bda87af6000ed0083e3bf7cc31c6686b670bd85cbc6da2d6e85

I get this transaction:
https://kovan.etherscan.io/tx/0x58e5a0fc7fbc849eddc100d44e86276168a8c7baaa5604e44ba6f5eb8ba1b7eb

Is it possible to decode raw transaction so that this hash is known before hand?
Note that I am storing private keys outside of applications such as geth/parity.

Best Answer

Ok, so asked it a couple of minutes too soon. As the name implies it's a hash, hash of what? Hash of your raw hex in example:

0xf86c258502540be40083035b609482e041e84074fc5f5947d4d27e3c44f824b7a1a187b1a2bc2ec500008078a04a7db627266fa9a4116e3f6b33f5d245db40983234eb356261f36808909d2848a0166fa098a2ce3bda87af6000ed0083e3bf7cc31c6686b670bd85cbc6da2d6e85

Hashed using keccak256 (for instance can be found here: https://wiki.parity.io/JSONRPC-web3-module#web3_sha3): and the result as expected is:

0x58e5a0fc7fbc849eddc100d44e86276168a8c7baaa5604e44ba6f5eb8ba1b7eb

So ended up being a short rhetorical question. However if someone has similar question... hope this helps!

Related Topic