I have a simple contract that at some point pays its users:

void dice::pay( name to, asset quantity, string memo ) {
     permission_level{ _self, "active"_n },
     "acornaccount"_n, "transfer"_n,
     std::make_tuple(_self, to, quantity, memo)

That code works fine and payments are sent, but it seems that action().send() can fail, i.e. it is a transaction and transactions can fail for multiple reasons -- no guarantees.

So, what is the right way to write a contract that retries every single failed action forever, no matter what that action is, in the current EOSIO CDT 1.6?

This is my current "apply" function:

extern "C" {
  void apply(uint64_t receiver, uint64_t code, uint64_t action) {
    if (code == "acornaccount"_n.value && action == "transfer"_n.value) {
      eosio::execute_action(eosio::name(receiver), eosio::name(code), &dice::acorn_transfer);
    } else if (code == receiver) {
      switch (action) { EOSIO_DISPATCH_HELPER(dice, (withdraw)(commit)(cancelcommit)(reveal)(collect)) }

I have tried to write this onerror/retry code before, and failed. I can't seem to find documentation or any complete, clear examples. And since onerror handling seems extremely difficult to test anyway, a documented and clear example that works would be very useful.

  • I have same problem...maybe..also. But I would like a code example wich transfer tokens in contracts...first off all only transfer tokens if the smartcontract run... Doy you know giving me full paying contrac example wich complied without errors on CDT 1.6? Tank You for your help.. – Efraim May 25 '19 at 12:11

Your Answer

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

Browse other questions tagged or ask your own question.