Are there any examples online for where I can see some examples of deferred transactions being created?
1 Answer
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.
-
2is that possible to stop deferred transaction which having been pushed in a contract ?– Harry MaCommented May 23, 2018 at 2:31
-
1
-
yes it's possible to stop a deferred transaction, check
cleos system
... the first parameter oftransaction.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
-
6who 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