The Ethereum Virtual Machine has three areas where it can store data- storage, memory and the stack, which are explained in the following paragraphs.
・Storage - store in persistent storage on blockchain.
・Memory - contract obtains a freshly cleared instance for each message call.
・Stack - all computations are performed on a data area called the stack
possible > move stack elements to storage or memory impossible > to just access arbitrary elements deeper in the stack without first removing the top of the stack. .
storage
- variable is a state variable on blockchainmemory
- variable is in memory and it exists while a function is being calledstored only during function execution.
calldata
- special data location that contains function argumentscontract Example {
uint256 thisIsAStack;
}
■ Good Article
Solidity supports three types of variables.
- State Variables − Variables whose values are permanently stored in contract storage.
- Local Variables − Variables whose values are present till the function is executed.
- Global Variables − Special variables exist in the global namespace used to get information about the blockchain. e.g) msg.sender, block.timestamp, block.difficulty