- Solidity allows you to choose the type of storage with the help of storage and memory keywords. A storage variable stores values permanently, whereas memory variables are persisted during the lifetime of a transaction.
- Local variables of struct, array, or mapping type reference storage by default if no explicit specification is given inside a function. The function arguments are always in memory and the local variables, other than array, struct, or mapping, are stored in the stack.
- Consider the following function. Here, the _a variable is of type memory and x is of type storage:
function fun(uint _a) { uint[] x;}
- The issue arises when these storage variables are uninitialized. An uninitialized storage variable can refer ...