FAQ
Last updated
Last updated
Ethereum's execution model deducts the full gas limit at the start of execution and refunds a portion of the gas at the end if applicable. However, if the gas limit is set too tightly (equal to the actual gas used before refunds), the refund cannot be processed, and the transaction fails with an out-of-gas error.
Gas is initially reserved: The EVM deducts the full gas limit at the beginning of execution.
Gas refund happens at the end: If a contract includes operations that delete storage variables (e.g., SELFDESTRUCT
, SSTORE
clearing a slot), the gas refund is only applied after execution completes.
If gas runs out before refunding, the transaction fails because the EVM does not get a chance to apply the refund.
Below is an example of a Uniswap V3 transaction deployed on Pharos Devnet, where the actual gas used was 4,618,680:
However, since the gas limit was set exactly equal to the gas used, the transaction failed.
To verify this behavior, we deployed the same transaction on Ethereum Sepolia Testnet, and observed the same failure due to the gas limit issue:
To ensure the transaction executes successfully, we need to set the gas limit slightly higher than the expected gas usage.