0

So I have a transaction. I have a transaction that I would like to manually calculate the hash:

{
  "hash": "0xf4584008cc70f2f532765a2f035a2525992a258b2d2afd6b49ad5b2857a6197d",
  "type": 2,
  "accessList": null,
  "blockHash": null,
  "blockNumber": null,
  "transactionIndex": null,
  "confirmations": 0,
  "from": "0x0936c90c59ecb79fc01C780f283CABfB9e118940",
  "gasPrice": {
    "_hex": "0x203f403384",
    "_isBigNumber": true
  },
  "gasLimit": {
    "_hex": "0xb41d",
    "_isBigNumber": true
  },
  "to": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
  "value": {
    "_hex": "0x00",
    "_isBigNumber": true
  },
  "nonce": 38,
  "data": "0xa9059cbb0000000000000000000000009418bfc542817e4320480990f34951351b0db5130000000000000000000000000000000000000000000000000000000002faf080",
  "r": "0x270e826d5bbf71fa492de0da460b06f0f586d007d05db364493d1bf70b4fc77e",
  "s": "0x4b4795d7c50cd4e56342ab3044cb3986f85278a4a2377dcc621589d8289bfaaf",
  "v": 1,
  "creates": null,
  "chainId": 0
}

My end goal is manually calculate the hash of the above transaction, compare it to the "hash" in the object, and then verify it with the signature (if there is an easier way to do this, please shout).

I started by using ethers.js, however I am unable to make things work. So I would like to make this work manually.

Can anyone help?

1 Answer 1

0

If you have the signed transaction(signedTrx) then you can use:

const txHash = ethers.utils.keccak256(signedTrx);
1
  • How is this signed trx calculated? signer.signTransaction gives a string that isn't actually correct here... Commented Nov 1, 2022 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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