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:


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.

  • 1
    Please correct me if I am wrong: after mining transaction you receive the same transaction hash as after getting keccak256 hash from raw tx? My tests show that keccak256 hash of raw signed tx is NOT equal to transactionHash generated by ethereum while mining. I would appreciate if somebody could tell me how exactly transactionHashes are generated as there is no iformation available even in yellow paper of ethereum. Jan 7 '18 at 17:36

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:


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


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

  • It is not a stupid question. In Bitcoin, a hash of the transaction is presented in the opposite endianness so even though you may think that there is only one way to represent a hash as a string, that is not the case. Oct 14 '18 at 18:22
  • 1
    Is this a hash of the signed transaction or the unsigned transaction? For the purposes of validating transaction data, can I derive a transaction hash just from the transaction data itself without knowledge of the private key? Oct 27 '19 at 20:26
  • 1
    This is hash from the signed raw hex. I don't imagine you could derive it from unsigned data, since unsigned transaction has different "raw" representation and as such the hash of this would be also different than the hash of signed hex.
    – Kristaps
    Oct 28 '19 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.