Search⌘ K
AI Features

Storage vs. Memory

Explore how Solidity handles reference data types using storage and memory. Understand the differences between permanent and temporary data locations, how to manipulate arrays in each, and their impact on contract behavior and gas usage.

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 ...