I am trying to figure out the way to set contract which has deferred transactions at run time from front-end.
Is it even doable? Any suggestions would be appreciated.

  • from front-end meaning from a user-facing interface? you can just process the user input and trigger a transaction to a contract that has an action which handles deferred transactions
    – confused00
    Commented Jul 30, 2018 at 14:18
  • Yes, from GUI. But if user has to provide the delay for deferred transaction, then don't we have to set a whole new contract or that already deployed contract can handle the dynamic delay? If yes, can you show me some piece of code how can I achieve that. Commented Jul 31, 2018 at 5:32
  • can't you just pass the delay as an argument to the function?
    – confused00
    Commented Jul 31, 2018 at 9:14
  • Yes, That's exactly what I am doing right now. Thanks for the clue. Commented Jul 31, 2018 at 9:53

1 Answer 1


If I understand your question correctly, you can send a deferred transaction like you usually would but defining the delay as a function parameter:

void send(account_name account, std::string message, uint64_t delay) { 
    eosio::transaction t{};
        eosio::permission_level(account, N(active)),
    t.delay_sec = delay; // Here you set the delay dynamically
    t.send(N(message), account);

you'd have to make sure you set the permissions right:

$ cleos set account permission account active '{"threshold": 1,"keys": [{"key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","weight": 1}],"accounts": [{"permission":{"actor":"contractaccount","permission":"eosio.code"},"weight":1}]}' owner -p account

and then you'd call the contract passing the delay at run-time

  • In your code above, I am little bit confused about othercontract, othermethod, contractargs._________ othercontract: is this the contract name? othermethod: is this the action name defined in cpp file which we have to execute after the given delay? contractargs: are they the arguments to the othermethod action name? Commented Jul 31, 2018 at 12:24
  • othercontract is the contract to which you want to send a deferred transaction, othermethod is the name of the action that you want to call, otherargs are the arguments passed to that action. I wrote a skeleton for this somewhere else if it helps (without dynamic delay)
    – confused00
    Commented Jul 31, 2018 at 12:41

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.