I have a action which execute the deferred transaction . Let I send the delay of 20 days . If I want to cancel the deferred transaction before 20 days . Is there any way I can do this ?

This is my action which I push to deferred the transaction .

void second::send(account_name from , account_name to ,asset  quantity,string  memo,uint64_t delay) {
            eosio::transaction t{};

        eosio::permission_level(from, N(active)),       
            t.delay_sec = delay;
            t.send(N(memo), from);

transfer( account_name from,
                      account_name to,
                      asset        quantity,
                      string      memo  ){....}

transfer is my action that execute the transaction .

  • How can we use the function defined in apply_context.hpp file to cancel a deffered transaction bool apply_context::cancel_deferred_transaction( const uint128_t& sender_id, account_name sender ) {....} – Nirdesh Kumar Choudhary Aug 3 '18 at 9:05
  • The absolute path of function 'cancel_deferred_transaction ()' is /eos/libraries/chain/include/eosio/chain/apply_context.hpp – Nirdesh Kumar Choudhary Aug 3 '18 at 9:14
  • You can import eosio library in your file to use it. – Rajat Chaudhary Aug 3 '18 at 10:47
  • Yes I found the library but what is context here , the parameter that I have to pass. – Nirdesh Kumar Choudhary Aug 3 '18 at 12:30
void send(const uint128_t& sender_id, account_name payer, bool replace_existing = false)

First parameter(sender_id) is the id of the deferred transaction. You can call cancel_deferred(sender_id) to cancel it.

See example in delegate_bandwidth on GitHub.

  • Rocky I have to make a new action in my contract that implement the method cancel_deferred(sender_id) and import transaction.h in my header file ? – Nirdesh Kumar Choudhary Aug 8 '18 at 10:02
  • 2
    yes, need a new action. – rocky802 Aug 8 '18 at 10:25
  • hello could I update the deferred transaction – user2872 Jan 25 at 13:19

Your Answer

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

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