4

In bitcoin-land, it's advised to batch transactions to send them to (a) reduce fees and (b) reduce network congestion.

Does the same apply to ethereum land? It seems that the to can be only one address / account. But can there be many froms?

Is there a benefit to doing so?

1
  • individual transaction can have only 1 from, and also only 1 to.
    – Nulik
    Commented May 11, 2018 at 22:02

2 Answers 2

3

On Ethereum, you can have a smart contract with batch transfer functionality, the function would take two arrays as input arguments, one for addresses and one for values. It would then iterate through the input arrays and call transfer as as many times as your length, however, it is a solidity anti-pattern to interact with untrusted external contracts in one single transaction.

2
  • But an individual transaction can only have one from and one to?
    – Shamoon
    Commented May 11, 2018 at 16:31
  • yes if you're complying to the ERC20 standard.
    – 6egic
    Commented May 11, 2018 at 16:38
2

It is possible to send ether from one address to several addresses in one transaction, but it is not possible to send from many addresses unless they are smart contracts.

In order to send ether to multiple addresses in one transaction, you just need to deploy the contract similar to this:

contract BatchSend {
    constructor () public payable {
        address (0x<first address>).transfer (<first amount>);
        address (0x<second address>).transfer (<second amount>);
        ...
        selfdestruct (address (0x<last address>)); // Will send all the rest
    }
}

and along with constructor call you will need to pass total amount of ether to be sent.

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.