I want to set up 64 boolean flags in a contract. What's the better option here?

a) bool[64]

b) uint64

And is there way to name each flag in Solidity like:

#define BIT_0 0

uint64 should be used for numbers that can be added and multiplied. If you want to perform bit operations, types like bytes8 should be better suited. A bool array is quite wasteful, as it takes a single byte per element. You can name the flags using constants: bytes8 constant bit_1 = 2**1;.

  • Could I also name the flags using uint8 ? @chriseth
    – alper
    Mar 28 '19 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.