Focus mode

Smart Contract Development with Solidity

Data locations

Code from video: https://solidity-by-example.org/data-locations/ 

You can access the video content in Turkish prepared by İTÜ Blockchain here: https://www.youtube.com/watch?v=MzvzBp9l3y0&list=PLby2HXktGwN4Cof_6a8YwlMrboX8-hs73&index=14 

There are 3 types of memory locations (data locations) in the EVM:

  • storage: Stored on the blockchain.
  • memory: Stored in a memory. Function is called and deleted as soon as the function is used as needed.
  • calldata: Stored in the call (transaction) when calling the function (msg.data). It can only be read.

When using reference types such as bytes, string, uint256[], struct in functions, it should be specified from which memory area these data will be taken.

Resources:

You can find detailed further information from Solidity Official documentation (in English):

https://docs.soliditylang.org/en/v0.8.15/internals/layout_in_storage.html#layout-of-state-variables-in-storage

https://docs.soliditylang.org/en/v0.8.15/internals/layout_in_memory.html#layout-in-memory

https://docs.soliditylang.org/en/v0.8.15/internals/layout_in_calldata.html#layout-of-call-data 

https://github.com/itublockchain/web3-bootcamp/tree/master/1x11_DataLocations


Comments

You need to enroll in the course to be able to comment!