Solidity Memory vs Storage – Understanding the Difference Between Memory and Storage in EVM

contract-designevmmemorystorage

What is the difference between Memory and Storage ?

From both the EVM point of view and the contract design one.

Thanks!

Best Answer

They are analogous to memory and hard drive storage in a computer. The contract can use any amount of memory (as long as it can pay for it of course) during executing its code, but when execution stops, the entire content of the memory is wiped, and the next execution will start fresh. The storage on the other hand is persisted into the blockchain itself, so the next time the contract executes some code, it has access to all the data it previously stored into its storage area.

Related Topic