12

Are there any examples online for where I can see some examples of deferred transactions being created?

1 Answer 1

16

It's super simple, from your contract just call the below code:

        transaction out{};
        out.actions.emplace_back(permission_level{_self, N(active)}, N(pet), N(feedpet), std::make_tuple(pet.id));
        out.delay_sec = 10;
        out.send(pet.id, _self);

It's basically wrap an action on a transaction object (so you must import eoslib/transaction.hpp on your header) and you set the quantity of seconds to defer the transaction, in the above case it's 10 seconds.

6
  • 2
    is that possible to stop deferred transaction which having been pushed in a contract ?
    – Harry Ma
    Commented May 23, 2018 at 2:31
  • 1
    what means first parameter of transaction.send?
    – baltazar
    Commented May 25, 2018 at 8:45
  • yes it's possible to stop a deferred transaction, check cleos system ... the first parameter of transaction.send is the id of the transaction you want to create Commented May 25, 2018 at 13:19
  • are deferred transactions visible the second they are sent? I want to use them to hide some information but reveal at a later time. Commented Aug 3, 2018 at 12:16
  • 6
    who will pay for CPU in case of a deferred or inline action, the contract or the initial caller? Commented Aug 27, 2018 at 0:25

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.