I notice the gas table states:

((value != 0) && (storage_location == 0)) ? 20000 : 5000

for SSTORE. What does it mean by storage_location?

1 Answer 1


((value != 0) && (storage_location == 0)) ? 20000 : 5000

This is basically saying that it costs 20,000 gas to set any given storage location - i.e. storage slot - from 0 to value, and 5,000 gas to change its value thereafter.

So storage_location in the above will mean whichever slot in the storage we are considering.

e.g. If we are considering slot number 5 in storage, then in the above pseudo-code storage_location will be set to 5, and we are checking whether its current value is 0.

Appendix G in the Yellow Paper puts it thusly:

Gsset   20000  Paid for an SSTORE operation when the storage value is set to non-zero from zero.
Gsreset 5000   Paid for an SSTORE operation when the storage value’s zeroness remains unchanged or
is set to zero
  • So, the gas cost of update operation is 5000, right? Apr 16, 2021 at 9:40
  • That's correct, yes. Apr 16, 2021 at 10:22

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.