Value Data Types

Learn about value, the first set of data types.

Data types in Solidity

As we’ve learned, Solidity is a statically typed programming language. This means that we have to provide the type of data we want a variable to hold when defining it and we cannot assign or reassign a value of a different type to this variable. This makes it vital to understand the different data types and what we can store in them.

Solidity uses two main types: value and reference. Reference variables store references to their data, while value variables store their data directly.

We’ll be making references to and modifying our existing contract code to exemplify these data types. In this code, the variables are defined but not assigned any values. When we attempt to retrieve variables defined like this, we receive the default value associated with the data type, as shown in the code widget below:

Get hands-on with 1200+ tech skills courses.