#include <eosiolib/eosio.hpp>
#include <eosiolib/transaction.hpp>
#include <lib/user.h>
using namespace eosio;
using namespace user;
class hello : public eosio::contract {
      using contract::contract;

     // @abi action 
      void hi( account_name user ) {
       print( "Hello, ", name{user} );
    //@abi action
     void signup(uuid_t Id, string Name,string mobileNum,uint64_t password,uint64_t gender)
     tableUsrde_t user(_self, _self);
    transaction out{};
        out.actions.emplace_back(permission_level{N(tester), N(active)}, N(tester), N(hello), std::make_tuple(0xff));
        out.delay_sec = 10;
            user.emplace(_self,[&](auto& record){
                record.userId = Id;
                record.userName = Name;
                record.usermobileNum =mobileNum;
                record.userpassword = password;
                record.usergender =gender;



EOSIO_ABI( hello, (hi)(signup))


typedef uint64_t    uuid_t;
typedef int8_t     positionType_t;
using namespace std;    
namespace  user{
    //@abi table tableuserdet i64
    struct tableUsrdet{
        uuid_t userId;
        string userName;
        string usermobileNum;
        uint64_t userpassword;
        uint64_t usergender;
        uuid_t primary_key() const {return userId;}
    typedef eosio::multi_index<N(tableuserdet),tableUsrdet > tableUsrde_t;

1) My requirement is a such way that signin action execute after 10 sec when I call cleos push action

2) But currently cleos push action run without delay

I dont know how deferred action work ? Is there any example or doc ? Please suggest

  • 3
    I suggest you edit the question and indent it using Markdown format so that the code bits become readable. – Mikko Ohtamaa Jun 22 '18 at 9:15
  • you need scheduled transaction – Jimmy Guo Jun 23 '18 at 10:43

What's tester and tester::hello() looking like? Your code may look ok or not depending on how those are implemented. Any small error may result in the whole thing failing with no helpful error message.

Here's a full example of something that works on my machine fine:



class sender : eosio::contract {
        sender (account_name account) : eosio::contract(account) {}

        void send(account_name account, std::string message) {

            eosio::transaction t{};
                eosio::permission_level(account, N(active)),
            t.delay_sec = 5;
            t.send(N(message), account);

EOSIO_ABI(sender, (send))



class recipient : eosio::contract {
        recipient(account_name account) : eosio::contract(account) {}

        void receive(std::string message) {

EOSIO_ABI(recipient, (receive))


$ cleos wallet unlock
$ cleos wallet keys
$ cleos account create eosio sender EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
$ cleos account create eosio recipient EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
$ cleos account create eosio controller EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
$ cleos set contract sender contracts/sender
$ cleos set contract recipient contracts/recipient
$ cleos set account permission controller active '{"threshold": 1,"keys": [{"key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","weight": 1}],"accounts": [{"permission":{"actor":"sender","permission":"eosio.code"},"weight":1}]}' owner -p controller
$ cleos push action sender send '["controller", "my_message"]' -p controller

The message should show up in nodeos output assuming it's configured with contracts-console=true

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.