Quiz Entry - updated: 2026.07.30
Solidity has three data-location keywords in common use — memory, storage, and calldata. What does each mean?
storage = permanent, lives on-chain beyond the function; memory = temporary, exists only during the function and can be modified; calldata = temporary and read-only (cannot be reassigned).
| Location | Lifetime | Mutable? |
|---|---|---|
storage |
Permanent, persists between calls | Yes |
memory |
Temporary, only during the function | Yes |
calldata |
Temporary, only during the function | No (read-only) |
State variables are automatically storage. Function parameters are temporary, so they must be memory or calldata. Use calldata when you will not modify the argument; use memory when you need to change it inside the function:
function addPerson(string memory _name, uint256 _num) public { ... }
You only specify a location for the special reference types — arrays, structs, and mappings. Value types like uint256 are handled automatically and reject a location keyword.
Go deeper:
Solidity docs: data location — storage vs memory vs calldata in full, with assignment behaviour.