2

Assume two dependent transactions A and B. Transaction B depends on transaction A and will fail if transaction A has failed.

I would like to estimate the gas limit required for the success of both transactions if executed sequentially. Estimating gas for each transaction separately does not work. While there is no problem with estimating gas for transaction A, estimating gas for transaction B without actually executing transaction A might return a wrong result. Transaction A has not yet happened and the state not changed.

In other words, how to estimate the gas limit for transaction B, given transaction A has completed successfully.

1

You can use this solution to sync the state of public ethereum chains into your local private blockchain in truffle (or embark) and then locally simulate the execution of both transactions in the correct causal order to properly estimate the gas cost.

| improve this answer | |
  • Any service that does this already? – amanusk Nov 27 '19 at 13:32
  • @amanusk None that i know of. Since Ganache supplies you with the functionality to fork a public chain into a local chain (and therefore already does all the difficult work, in a single command), I don't really see the necessity of such a service. It even does not download the complete chain, it only makes calls to the nodes if it needs some data during execution. – sea212 Nov 27 '19 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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