Hot answers tagged

2

(I'm sure this has come up before. If someone can find a previous answer then please duplicate... ) From the Yellow Paper, Appendix G, you'll see the following line: Gsset - 20000 - Paid for an SSTORE operation when the storage value is set to non-zero from zero. Meaning the first time you write a variable to storage, it's more expensive by 20,000 gas....


1

This is not unique to arrays, but to any state-variable in your contract. Changing from zero to non-zero costs more gas than changing from non-zero to non-zero.


1

No. It would be expensive and it would not scale. The name of the game is to economize on writes and avoid loops. It's so important that your approach to problems like this may seem counter-intuitive, at first. You have to work out what the value would be if the data was updated in place. For that, you would just need to know the original number and the ...


Only top voted, non community-wiki answers of a minimum length are eligible