Suppose that we have a transaction that calls a contract method with an i.e. 200,000 gas limit. While the transaction is mining, the called contract finds out that it will run out of gas before completion (We cannot estimate required gas beforehand for some reasons). We have enough eth available in the contract and also in the tx.origin
account. Is there any way to use either contract's or EOA balance to re-balance the limit and complete the execution?
-
1no. But there are offchain methods to estimate gas, usually metamask do it right. Anyway you can send much more gas than necessary and you will pay just for what the contract used– Majd TLCommented May 15, 2022 at 9:06
1 Answer
The executed contract method can't make changes to gas limit, the tx originator must replace that tx with another one in order to change it.
Change to a tx must be done by sending another tx with the same nonce but using higher gas price. If you managed to send it before the previous one gets mined, most likely (but not guaranteed) that a miner will mine it first, causing the older tx with same nocne to be removed from the mempool.