I want to develop a contract and save data by using emplace function. Below is my code:

offer_bets_index offerbets(_self, player);

eosio::print("begin to write db\n");

auto bets_itr = offerbets.emplace(_self, [&](auto& offerbet) {
    eosio::print("new offer bet");
    uint64_t id = offerbets.available_primary_key();
    eosio::print("new available key:", id);
    offerbet.id        = id;
    offerbet.player    = player;
    offerbet.draw      = draw;
    offerbet.bet       = bet;
    offerbet.buycnt    = buycnt;
    offerbet.buylottos = buylottos;
    offerbet.buytime   = buytime;
eosio::print("end write", bets_itr->id);

Only the first eosio::print content show correctly, but the print content inside the lambda function and the last print content didn't show. Seems like the emplace function didn't been executed in the action?

Anybody knows why?? Thanks!

  • Did you try to check your node console window/log? Sometimes for me the output messages are only there and does not show anything at my cleos... not sure why... May 14, 2018 at 17:55
  • 1
    @LeoRibeiro This problem also happen to me. I found that, if you add -j option with your cleos command, you will find the console log.
    – yang24201
    May 15, 2018 at 1:25

2 Answers 2


I found that, the abi file generated by eosiocpp was I expected. Check your abi file and pay attention to your @abi annotation, maybe you will fix this problem.This is my solution.


maybe you can remove the "\n" in the first "print" function, i also met this problem. but not sure what the real reason is.

  • Not work for me, but thanks for your suggestion. I suppose the eosio::print function print the log in asynchronous thread, so that sometimes the log will lost.
    – yang24201
    May 15, 2018 at 4:25
  • @Harry Ma i also met this problem,and remove the "\n".but how output "\n"?
    – yilin wang
    Dec 20, 2018 at 2:30

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.