I am trying to use this :

struct [[eosio::table]] tokens {
                name token;
                std::map<name,asset> blnc;
                uint64_t primary_key() const { return token.value; }

But I get the following error :

error: error reading '/home/ubuntu/exchange.cpp' 1 error generated. Error while processing /home/ubuntu/exchange.cpp. abigen error

Is there a problem with using maps in tables in eosio-cpp?

  • 1
    Where is template argument for your map? What version of CDT do you use?
    – conr2d
    Jan 24, 2020 at 2:44

1 Answer 1


I have used maps in a table without issue before, my table looks like this:

  class [[ eosio::table("ram"), eosio::contract("automatedres") ]] ram_t
    eosio::time_point created;

    std::map< eosio::name, int64_t > ram_usage;
    std::map< eosio::name, bool > paid_chex; ///@todo Create modifier and accessor functions
    uint64_t primary_key() const { return created.sec_since_epoch(); }
    auto set_created(eosio::time_point const &x) { created = x; }
    auto get_created() const { return created; }
  typedef eosio::multi_index< eosio::name("ram"), ram_t > ram_table;

If this doesn't work for you, then perhaps you are using an older version of the eosio.cdt or something. Upgrade to the latest version of the software and check again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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