25: Data Location
Data Location
Data Location is a concept within Solidity, which refers to the memory or storage locations where data is stored. Knowing where data is located can help you write more efficient smart contracts.
Memory
Memory is a volatile location where data is stored temporarily while a function is being executed. All data stored in memory is automatically cleared once the function ends.
Example:
Storage
Storage is a persistent location where data is stored on the blockchain. Data stored in storage is accessible and modifiable until a contract is destroyed or removed from the blockchain.
Example:
Stack Data Location
In Solidity, data location refers to the place where the data is stored. It can be either storage, memory, or calldata.
Storage is the permanent storage area for a contract’s data. All data stored in storage will persist until it is explicitly deleted.
Memory is a temporary storage area. It is volatile, meaning that the data is lost when the function call ends.
Calldata is the read-only area where the arguments passed to the contract are stored.
Examples:
Storage
Memory
Calldata
That's it for the lesson 25! In the next lesson, Inheritance
Last updated