Think Twice Before Using Enums in Solidity Smart Contractsby@olekon86
993 reads
993 reads

Think Twice Before Using Enums in Solidity Smart Contracts

by Oleg4mAugust 20th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Solidity smart contracts can be characterized as a type or state. Enums can be encapsulated within only one contract and are never mentioned in other files. However, DApps usually consist of several contracts connected with each other. The problem appears when the same enum appears in more than one contract. It can’t convert setState function argument StateC to its version of the enum and therefore fails. The explicit conversion from integer checks at runtime that the value lies inside the range of theenum causes a failing assert otherwise.

Company Mentioned

Mention Thumbnail
featured image - Think Twice Before Using Enums in Solidity Smart Contracts
Oleg HackerNoon profile picture
Oleg

Oleg

@olekon86

Software developer, Ethereum and beyond

About @olekon86
LEARN MORE ABOUT @OLEKON86'S
EXPERTISE AND PLACE ON THE INTERNET.

Share Your Thoughts

About Author

Oleg HackerNoon profile picture
Oleg@olekon86
Software developer, Ethereum and beyond

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here
L O A D I N G
. . . comments & more!