Is it possible sending ether to multiple addresses in one go, better called batch sending? I want to make an API to transfer ether to 100 address at once so that I do not need to make 100 transactions.


Here is Dapp to make it easier for you: https://multisender.app

If you want to do it yourself, here is some code for you

contract MultisenderApp {

function multisendEther(address[] calldata _contributors, uint256[] calldata _balances) external payable {
    uint256 total = msg.value;
    uint256 i = 0;
    for (i; i < _contributors.length; i++) {
        require(total >= _balances[i]);
        assert(total - _balances[i] > 0);
        total = total - _balances[i];
        (bool success, ) = _contributors[i].call.value(_balances[i])("");
        require(success, "Transfer failed.");

this way, you can be sure that whoever interacts with this function, won't take more eth than he/she should.

| improve this answer | |

This can be kinda of delicate at times, but web3 does support batch requests https://github.com/ethereum/wiki/wiki/JavaScript-API#batch-requests Here is their example on their site. I can include an example for sending ether if this is not clear

var batch = web3.createBatch();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));
batch.add(web3.eth.Contract(abi).at(address).balance.request(address, callback2));

The Specific example would be something akin to eth.sendTransaction({from:sender, to:receiver, value: amount})

var batch = web3.createBatch();
batch.add(web3.eth.sendTransaction({from:sender, to:receiver, value: amount}));
batch.add(web3.eth.sendTransaction({from:sender, to:receiver2, value: amount2}));

Just an FYI Batching requests do not make them faster! Making many requests at once will sometimes be faster, as requests are processed asynchronously. Batch requests are mainly used to ensure events happen in serial.

| improve this answer | |
  • i just want to send ether. why do i need to include contract abi? – rahul saini May 8 '18 at 14:19
  • This was the example on their site for generic batch requests which didn't show sending but would be very similar, I can edit it for specifically sending ether if that will help. – Lucas Hendren May 8 '18 at 14:20
  • I want to make 10 ether transaction to 10 different addresses in the single transaction fee. does it possible through batch transaction? – rahul saini May 8 '18 at 14:23
  • I added in an example for sending ether – Lucas Hendren May 8 '18 at 14:35
  • 1
    will try and reach you soon – rahul saini May 8 '18 at 14:44
function sendBatch(address[] _addrs) public payable {
    for(uint i = 0; i < _addrs.length; i++) {

This simple solidity function would do exactly what you're asking about. You would just need to provide an array of addresses when executing the function and it will split the ETH you send to all those addresses evenly.

| improve this answer | |

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.