Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching ethers to get transaction hash #12

Closed
vimwitch opened this issue Nov 8, 2022 · 2 comments
Closed

Patching ethers to get transaction hash #12

vimwitch opened this issue Nov 8, 2022 · 2 comments

Comments

@vimwitch
Copy link

vimwitch commented Nov 8, 2022

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.

@Divide-By-0
Copy link
Owner

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.

@vimwitch
Copy link
Author

vimwitch commented Nov 8, 2022

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.

@vimwitch vimwitch closed this as completed Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants