2.7. State Variables
Syntax
StateVariableDefinition = (* type_name: *) TypeName
(* attributes: *) StateVariableAttributes
(* name: *) IDENTIFIER
(* value: *) StateVariableDefinitionValue?
(* semicolon: *) SEMICOLON;
StateVariableDefinitionValue = (* equal: *) EQUAL
(* value: *) Expression;
StateVariableAttributes = (* item: *) StateVariableAttribute*;
StateVariableAttribute = (* variant: *) OverrideSpecifier (* Introduced in 0.6.0 *)
| (* variant: *) CONSTANT_KEYWORD
| (* variant: *) INTERNAL_KEYWORD
| (* variant: *) PRIVATE_KEYWORD
| (* variant: *) PUBLIC_KEYWORD
| (* variant: *) IMMUTABLE_KEYWORD (* Introduced in 0.6.5 *)
| (* variant: *) TRANSIENT_KEYWORD; (* Introduced in 0.8.27 *)
State Variables
State variables are variables whose values are permanently stored in contract storage.
contract MyContract {
uint myStateVariable;
}
Note
This section is under construction. You are more than welcome to contribute suggestions to our GitHub repository.