Member-only story

Solidity Tutorial: all about Enums

Jean Cvllr
9 min readAug 1, 2019

The word Enum in Solidity stands for Enumerable. They are user defined type that contain human readable names for a set of constants, called member. The data representation for an enum is the same as the one in the C language.

Table of Contents

  1. How and When to create Enums?
  2. Enums explained with a card deck
  3. Accessing an Enum value
  4. Modifying an enum value
  5. Transition through different Enums values
  6. Using Enums with modifiers
  7. Represent Enums as Strings
  8. Using Hash Functions with Enums
  9. Use Enums as a KeyType in Mappings
  10. What you can’t do with Enums in Solidity?

1. How and When to create Enums?

A classical example of an Enum would be a deck of card, to represent:

> The suits (Spades, Clubs, Diamonds, Hearts).

> The ranks / values (2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, King, Queen, Ace).

enum Value { Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jean Cvllr
Jean Cvllr

Written by Jean Cvllr

Smart Contract engineer at @LUKSO. Full Stack Developer. https://github.com/CJ42

Responses (4)

Write a response

choice;

should be `status` here I think

Awesome writeup

Thank you Jean. I need a clarification please:
From your explanation, I learnt that keccak256() only takes in bytes as an input but with this, I noticed it took my string input parameter with no error. Any explanation?
function…