Enums

Learn to work with enums in Solidity.

We'll cover the following

Enums, or enumerations, offer a convenient way to establish custom types comprising a set of named constants. Enums come in handy when we wish to define a variable that should only assume one among a small array of potential values. This clarity enhances the safety of our contracts because enums restrict variables to a known set of values and thus reduce the likelihood of errors.

The typical syntax for defining an enum in Solidity looks like this:

Get hands-on with 1400+ tech skills courses.