There are two types of memory area associated with contracts: storage and memory. Storage is a value store where all contract state variables are stored and are only changed by a transaction. Memory is a temporary storage location that is cleared for each message call. In this recipe, you will learn how to use these types efficiently, based on your requirements.
Using storage and memory efficiently
How to do it...
-
State variables are always stored in storage, and function arguments are always in memory.
- The memory location of a variable can be explicitly specified with the storage or memory keywords:
uint storage sum;
uint memory calc;
-
Local variables created for struct, array, or mapping types always reference storage...