Variables, Consts & Immutable
Last updated
Last updated
There are 3 types of variables in Solidity:
local
Declared inside a function.
Not stored on the blockchain.
state
Declared outside a function.
Stored on the blockchain.
global
Provides information about the blockchain.
Constants are variables that cannot be modified
Their value is hard coded into the bytecode of the contract
Using constants can save gas cost
Immutable variables are like constants
Values of immutable variables can be set inside the constructor
but cannot be modified afterwards