I have a simple enum (or enum class, neither one is working )

enum vote_option {
  upvote = 0,

and a table which will store a value of that enum type.

struct [[eosio::table]] poll
  uint64_t key;
  vote_option opt;

  uint64_t primary_key() const { return key; }

And the problem is the build is fine, but when I even get table I've got

Error 3015004: The type defined in the ABI is invalid
Error Details:

Has anyone experienced this kind of problem ?

I use eosio.cdt v 1.6.2 and eosio v1.8.4 .


If you use a custom type you must also define the type to a built in type.

For instance, your custom enum is actually a uint8_t type.

You'll need something like ..

typedef uint8_t vote_option;

Put that after you declare your custom enum. Your ABI file will correctly set vote_option as uint8_t.

  • So, you agree that we can't use enum typed members in tables. The same goes for enum classes with underlying type specified. – Tigran Sahakyan Oct 10 at 9:04
  • I have personally used the suggestion I gave and it worked fine. I just had to declare the enum and then specify it's type to be picked up by the ABI. – netuoso - EOS Titan Oct 10 at 9:08
  • What I can't understand is how do you declare the enum and then typedef the same name. You can't have enum and typdefed type at the same time. – Tigran Sahakyan Oct 10 at 10:51
  • Right so you have a name for the enum type. Then you typedef the uint8_t, and use the typedef name in place of the enum type. In the end, the enum is a declaration of a certain type of objects, in this case I used the uint8_t example. github.com/eostitan/delphioracle/blob/write-hash/include/… this example might give you more clarification – netuoso - EOS Titan Oct 10 at 13:54
  • 1
    Thank you, fully understood ;) Before marking your answer as accepted, could you please edit it to make it clearer. – Tigran Sahakyan Oct 10 at 18:12

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.