Think Twice Before Using Enums in Solidity Smart Contracts

Written by olekon86 | Published 2019/08/20
Tech Story Tags: solidity | smart-contracts | programming | ethereum | enum | solidity-enums | blockchain | latest-tech-stories

TLDR 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.via the TL;DR App

no story

Written by olekon86 | Software developer, Ethereum and beyond
Published by HackerNoon on 2019/08/20