Reference Types

Learn about the storage types in Solidity and the difference between value types and reference types.

An important distinction to note is that arrays, unlike the other types we've previously used, are classified as reference types. Since arrays are just the first example out of many reference types we'll learn in this course, it's important to understand the commonalities between all reference types since we'll start using them more and more as we progress.

We'll also learn about the differences between various data locations in smart contracts, an important topic that's a frequent source of confusion for new Solidity programmers.

Value types vs. reference types

In Solidity, types are divided into value types and reference types. So far in this course, all the variable types that we've been using have been value types. This includes uint, bool, address, etc.

What separates value types from reference types is that if we assign a value type to another variable and then change it, the change doesn't affect the original variable.

Get hands-on with 1200+ tech skills courses.