Member-only story
Hitchhikers Guide to the EVM
Gas Golfing by Optimizing Storage
This article is a write-up of a talk presented at SmartCon #1.
Gas golfing is the process of optimizing the existing functionality of a smart contract without actually changing what it does. Specifically, optimising a contract’s use of storage is where some of the biggest wins can be found. With that being said…
What is storage in Solidity?
Storage is any data that is persistent between transactions. It is often stored for extended periods of time and can be accessed in future transactions. In other languages, we might call these “Instance Variables” or “Class Variables”.
There is a catch with storage variables, though. They are, in fact, one of the most expensive things that a contract can play around with.
Why is Storage Expensive?
To explain why this is the case in a decentralized world, let’s first imagine a centralized one.
On a centralized server, storage is stored in a single place, usually a database. It’s predictable, so as more users use this…