According to EIP-1087 https://eips.ethereum.org/EIPS/eip-1087 , it take 20,000 gas to set a slot from 0 to non-zero with SSTORE while it takes only 5000 gas for any other change. Why does 0 to non-0 change take higher gas than any other change?


This is a form of state or storage rent.

When you change a state slot from 0 (the default) to non-0, you are increasing the size of the overall state data. The overall blockchain data - the "world state" - is 256-bits bigger than it was, and you are paying for that privilege.

In the real world, this means you are storing extra data on the HDDs/SSDs of anyone running a full or archive node.

If you're only changing the data from a non-0 value to another non-0 value, you are not increasing the size of the data, and not asking everyone running a node to increase the use of their storage hardware.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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