Divide-By-0 / ideas-for-projects-people-would-use

Every time I have an idea, I write it down. These are a collection of my top software ideas -- problems I think enough people have that don't have solutions. I expect you can reach a decent userbase if marketed correctly, as I am surely not the only one with these problems.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.