6

I want to create a deferred transaction that can be executed using cleos, is this possible? If so, how?

  • I tried using cleos push transaction with a modified json file. It got processed by cleos but it never did show up in the blockchain... – Jacques Whales Aug 21 '18 at 23:49
3

Update 19th September: v1.3.0 added a --delay-sec flag to cleos push action so you can now set a delay for your action from cleos directly.


I can't see anything in programs/cleos/main.cpp that would allow this directly.

The only way that I can think of to do this via cleos is to push an action to a contract that allows you to send deferred transactions; example:

$ cleos push action account send '["from", "to", "10.0000 EOS", "memo", 50]' -p from

And account::send can be something as follows (copied from an answer I made somewhere else):

void account::send(account_name from, account_name to, asset amount, string memo, uint64_t delay) { 
    eosio::transaction t{};
    t.actions.emplace_back(
        eosio::permission_level(from, N(active)), // with `from@active` permission
        N(eosio.token), // You're sending this to `eosio.token`
        N(transfer),   // to their `transfer` action
        std::make_tuple(from, to, amount, memo));  // with the appropriate args
    t.delay_sec = delay; // Set the delay
    t.send(eosio::string_to_name(memo.c_str()), from); // Send the transaction with some ID derived from the memo
   }
};

Set permissions

 $ cleos set account permission <sender-account> active '{"threshold": 1,"keys": [{"key": "<sender-pubkey>","weight": 1}],"accounts": [{"permission":{"actor":"<contract-account>","permission":"eosio.code"},"weight":1}]}' owner -p <sender-account>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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