We have 2 identical transactions, one spends 22409, and the other 37345 gas, why so?



1 Answer 1


The difference of ~15,000 makes me believe the difference is in the balances before hand. A SSTORE operation (change to a storage slot) in the EVM has different costs based on the value pre-execution and post-execution. If the pre-value is 0 and the post-value is non-zero, it costs 20k. If the pre-value is non-0, and the post-value is 0 it costs 5k and a 15k refund is added to the refund balance. If the pre-value is non-0 and the post-value is non-0, it costs 5k.

The transaction that cost ~22k is likely one where the sender and receiver have non-0 balances before, and the sender has a 0 balance after. So there is a 5k+5k charge for updating both balances, and a 15k refund for the zeroing of the sender balance.

The transaction that cost ~37k is likely one where both have a non-zero pre and post balance.

EDIT: You can actually see these to be accurate if you click the State Changes tab on the transactions on Etherscan.

  • 1
    Thank you! I missed the fact that the balance of the sender becomes 0, and geth debug trace on etherscan does not display refunds.
    – AleXau
    Apr 3, 2019 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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