-
Notifications
You must be signed in to change notification settings - Fork 172
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
estimateGas
using gasleft()
#39
Comments
Sorry what exactly do you mean here? |
Apologies for the confusion. I meant a function that can be used to estimate gas for multiple transactions in a single call, that returns those estimates separately for each call. Similar to |
In theory you could, but it won't be very accurate or useful—the sum of the individual call gas estimates won't equal the aggregated call gas limit / gas usage for various reasons. Gas costs vary by a lot of factors cold/warm addresses, cold/warm storage slots, different refund amounts based on total gas usage, etc. What is your use case for needing estimates of individual calls if they are going to be submitted together via something like |
Yeah, it wont be accurate. The use case is to just be able to estimate gas usage of multiple transactions in a single RPC call. And the individual calls need not exactly be submitted together. Yes, that does cause the gas costs to vary very much. But just wondering if its still possible to get close to it and since Multicall is already a public good with very useful utility functions, something like this would also belong here. |
The JSON-RPC spec supports batching, so you can batch multiple individual |
Yes, but I had seen Alchemy documentation recommending against it here: And I believe it also adds to the CUs and pushes the rate limits -- prevention of which is another advantage of batching them |
But I guess JSON RPC batching is the best bet atm among the options |
Yea either batch or individual txs is probably your best bet. Gas estimation can get tricky and I don't think solving it at the contract level is too useful / the right solution. It will also simply not work for a lot cases, such as when a call needs to come from a certain sender. The nodes use a binary search to find the gas limit so the tx gets executed many times, so does make sense if it's pricey in terms of CUs unfortunately 😕 |
JSON RPC batching is very inefficient if aiming for performance/speed: ethers-io/ethers.js#62 (comment) Apparently JSON RPC batching executes the requests are performed serially. |
Would it be possible to add another utility function equivalent to do multiple
eth_estimateGas
with somegasleft()
magic ✨Guess its too hard to get it right
The text was updated successfully, but these errors were encountered: