Solidity Gas Limit – Can Gas Limit Get Increased While Transaction Is Executing?

gasgas-limitout-of-gassolidity

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?

Best 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.

Related Topic