4

How can i send ether to multiple address in one transaction by paying one transaction fee. Like i want to publish multiple transaction at one go so i can incur only one transaction fee.

5
  • In a contract... Sep 9, 2020 at 11:34
  • can it be done without smart contract ? Sep 9, 2020 at 14:12
  • No, it cannot... Sep 9, 2020 at 14:28
  • Using web3 batch also require contract? Sep 9, 2020 at 14:58
  • That wouldn't impose a single transaction though. Sep 9, 2020 at 15:19

3 Answers 3

1

How can I send ether to multiple addresses in one transaction in order to pay transaction-fee once?

By aggregating several transfers in a contract constructor, and then deploying that contract.

For example:

pragma solidity 0.6.12;

contract Payer {
    constructor(address payable[] memory clients, uint256[] memory amounts) public payable {
        uint256 length = clients.length;
        require(length == amounts.length);

        // transfer the required amount of ether to each one of the clients
        for (uint256 i = 0; i < length; i++)
            clients[i].transfer(amounts[i]);

        // in case you deployed the contract with more ether than required,
        // transfer the remaining ether back to yourself
        msg.sender.transfer(address(this).balance);
    }
}
1

Easy way: https://cointool.app

Harder way:

Source code: https://github.com/rstormsf/multisender/blob/master/contracts/contracts/multisender/UpgradebleStormSender.sol

function multisendToken(address token, address[] _contributors, uint256[] _balances) public hasFee payable {
uint256 total = 0;
require(_contributors.length <= arrayLimit());
ERC20 erc20token = ERC20(token);
uint8 i = 0;
for (i; i < _contributors.length; i++) {
    erc20token.transferFrom(msg.sender, _contributors[i], _balances[i]);
    total += _balances[i];
}
setTxCount(msg.sender, txCount(msg.sender).add(1));
Multisended(total, token);

}

0

The fee you pay when sending ether to multiple transactions is about the same you'd pay if you sent them separately. The gas calculations are pretty much the same if I'm not mistaken.

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.