AI Features

Storage vs. Memory

Learn about the differences between storage and memory in Solidity.

Storage and memory

We already know that reference data types don’t hold value directly; instead, they store the location of the data. This way, two different variables can point to the same location, where any change to one variable can affect the other one. When defining reference data type variables, we must specify the data location using storage or memory.

In Solidity, storage refers to a permanent location for the defined data. Data stored in storage is permanent and remains between function calls. However, ...