Skip to main content
5 of 6
edited body

In a smart contract, you could do this by emplacing multiple actions into a single transaction, as follows:

transaction transfer;
transfer.actions.emplace_back(eosio::permission_level {_self, N(active) }, N(eosio.token), N(transfer), std::make_tuple(from_account, to_account_1, quantity_to_send, std::string("memo")));
transfer.actions.emplace_back(eosio::permission_level {_self, N(active) }, N(eosio.token), N(transfer), std::make_tuple(from_account, to_account_2, quantity_to_send, std::string("memo")));
transfer.actions.emplace_back(eosio::permission_level {_self, N(active) }, N(eosio.token), N(transfer), std::make_tuple(from_account, to_account_3, quantity_to_send, std::string("memo")));
transfer.send(0, _self, false);

You can do it with cleos by creating the json for each transfer, as follows:

cleos transfer from_account, to_account quantity memo -d -j -s 

This creates json output do this for all the transfers you want to do it for, it should look like this:

{
  "expiration": "2018-10-20T10:54:37",
    "ref_block_num": 92,
    "ref_block_prefix": 276911189,
    "max_net_usage_words": 0,
    "max_cpu_usage_ms": 0,
    "delay_sec": 0,
    "context_free_actions": [],
    "actions": [{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
        "actor": "fromaccount",
        "permission": "active"
      }
      ],
      "data": "00f2d4142123e95d0040c85353840ccd102700000000000004454f5300000000046d656d6f"
    }
    ],
    "transaction_extensions": [],
    "signatures": [],
    "context_free_data": []
}

{
  "expiration": "2018-10-20T10:54:42",
    "ref_block_num": 102,
    "ref_block_prefix": 3271438144,
    "max_net_usage_words": 0,
    "max_cpu_usage_ms": 0,
    "delay_sec": 0,
    "context_free_actions": [],
    "actions": [{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
        "actor": "fromaccount",
        "permission": "active"
      }
      ],
      "data": "00f2d4142123e95d0080c85353840ccd102700000000000004454f5300000000046d656d6f"
    }
    ],
    "transaction_extensions": [],
    "signatures": [],
    "context_free_data": []
}

{
  "expiration": "2018-10-20T10:54:45",
    "ref_block_num": 109,
    "ref_block_prefix": 718898287,
    "max_net_usage_words": 0,
    "max_cpu_usage_ms": 0,
    "delay_sec": 0,
    "context_free_actions": [],
    "actions": [{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
        "actor": "fromaccount",
        "permission": "active"
      }
      ],
      "data": "00f2d4142123e95d00c0c85353840ccd102700000000000004454f5300000000046d656d6f"
    }
    ],
    "transaction_extensions": [],
    "signatures": [],
    "context_free_data": []
}

To make this into one transaction, copy and paste each of the actions into the first json output, as follows:

{
  "expiration": "2018-10-20T10:54:37",
    "ref_block_num": 92,
    "ref_block_prefix": 276911189,
    "max_net_usage_words": 0,
    "max_cpu_usage_ms": 0,
    "delay_sec": 0,
    "context_free_actions": [],
    "actions": [{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
        "actor": "fromaccount",
        "permission": "active"
      }
      ],
      "data": "00f2d4142123e95d0040c85353840ccd102700000000000004454f5300000000046d656d6f"
    },{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
        "actor": "fromaccount",
        "permission": "active"
      }
      ],
      "data": "00f2d4142123e95d0080c85353840ccd102700000000000004454f5300000000046d656d6f"
    },{
      "account": "eosio.token",
      "name": "transfer",
      "authorization": [{
        "actor": "fromaccount",
        "permission": "active"
      }
      ],
      "data": "00f2d4142123e95d00c0c85353840ccd102700000000000004454f5300000000046d656d6f"
    }
    ],
    "transaction_extensions": [],
    "signatures": [],
    "context_free_data": []
}

Finally, save this json file, and execute it as follows:

cleos push transaction eosio.token transfer my_json_file.json