- If you are sending all these transactions from one account, Than all you could do :
void Democontract::demoaction(account_name from,vector &tos,vector &memos,string memo,uint64_t delay){
eosio::transaction txn{};
// max_delay in EOS is 45 days(in seconds)
uint64_t max_delay = 10;
string appending_char = "a";
eosio_assert((((memo.length() == 11) || (memo.length() == 12))), "check the length of memo");
if (memo.length() == 11){
memo = memo.append(appending_char);
}else if (memo.length() == 12){
memo = memo.substr(0, 11);
}
if ((delay <= max_delay)){ // here we are reaching the limit to deferred time so now final execution is near.
//Here you can do calculations according to your requirement.
txn.actions.emplace_back(
eosio::permission_level(from, N(active)),
N(youraccount),
N(intermediate),
std::make_tuple(from, tos, memos, memo));
txn.delay_sec = delay;
txn.send(eosio::string_to_name(memo.c_str()), from);
}else{ //Here we again call this action after certain period
//remember this recursion is not in stack
print(memo);
txn.actions.emplace_back(
eosio::permission_level(from, N(active)),
N(youraccount),
N(demoaction),
std::make_tuple(from, tos, memos, memo, delay - max_delay));
txn.delay_sec = max_delay;
txn.send(eosio::string_to_name(memo.c_str()), from);
print("Inside repeat______________________________________\n");
}
}
void Democontract::intermediate(account_name from,vector<account_name> &tos,vector<string> &memos,string memo)
{
eosio::token t(N(eosio.token));
const auto sym_name = eosio::symbol_type(S(4, EOS)).name();
const auto my_balance = t.get_balance(from, sym_name);
print("\n start the transactions __________________\n");
for (int i = 0; i < tos.size(); i++)
{
print(name{tos[i]});
//just a demo calculation to put value in tosend(How many EOS we send)
eosio::asset tosend = (my_balance * 0.01 * 100) / 10000;
Democontract::finalpush(from, tos[i], tosend, memos[i], 0);
}
print("\n finish with the pushing transctions after delay is over ________________\n");
}
// @abi action
void Democontract::finalpush(account_name from,account_name to,asset quantity,string memo,uint64_t delay)
{
require_auth(from);
eosio::transaction txn{};
txn.actions.emplace_back(
eosio::permission_level(from, N(active)),
N(eosio.token),
N(transfer),
std::make_tuple(from, to, quantity, memo));
txn.delay_sec = delay;
txn.send(eosio::string_to_name(memo.c_str()), from);
}
so you need to pass all argument to demoaction.
- If you are using multiple accounts to debit and multiple accounts to credit. than you also need to send a vector of account(just like `from' in my case here)
Here we push all transfer action in the end only. You can see in this code and put logic whatever you want in calculation part if you send some other parameters.