55 - Data Location
Reference Types & Data Location: Every reference type has an additional annotation — the data location where it is stored. There are three data locations: memory
, storage
and calldata
.
-
memory
: whose lifetime is limited to an external function call -
storage
: whose lifetime is limited to the lifetime of a contract and the location where the state variables are stored -
calldata
: which is a non-modifiable, non-persistent area where function arguments are stored and behaves mostly like memory. It is required for parameters of external functions but can also be used for other variables.
- Reference Types -> Data Location Annotation
memory
,storage
,calldata
memory
: functionstorage
: contractcalldata
: non-modifiable, non-persistent, external fn parameters
- Impact -> Scope
- Security: Persistence