Patching ethers to get transaction hash
vimwitch opened this issue · comments
Hey I was perusing the list and saw the last item:
Patch ethers.js to add a function that calculates the transaction hash, without having to send the transaction. keccak256 on the signed transaction doesn't work, and there is no built in function to do so even though it is possible
This should work, I often use an approach where I calculate a tx hash using keccak(signedTx)
then use provider.waitForTransaction
using that hash. I often call waitForTransaction
before the transaction has been sent (e.g. it's sitting in the local database queue of transactions).
Here is an example queuing the transaction and returning the hash.
And Here is an example waiting for one of those hashes.
Got it! Yeah -- the fact signed transaction has to only be on nonce, to, gasPrice, data to get the hash, should be something abstracted away in the library. I also have to resort to manual calculation, but would be ideal to add a function to ethers directly.
Ah true, like auto determining those values like in sendTransaction
or whatever. Then having a function that does all of it like calculateTransactionHash
. Makes sense.