0

This question already has an answer here:

Bitcoin allows multiple tx_in with multiple tx_out per tx message.

May I know if Ethereum supports this or is it a 1 tx_in to 1 tx_out and for multiple addresses, the tx_out would have to be some sort of multiple-sending contract ?

marked as duplicate by eth May 9 '18 at 9:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

I think the correct answer is that this is not possible in Ethereum, at least not in the way that is allowed in Bitcoin. The example provided by the answer above by @Sumit is just a loop over many addresses, causing many "1 tx_in to 1 tx_" transfers.

You do not need to have a contract to do this, you can use js. Assume addresses is the array that contains the addresses.

var i; 
for (i = 0; i < addresses.length; i++) {
    web3.eth.sendTransaction({from:"your_address", to:addresses[i], value:web3.toWei(amount_in_ether,"ether")}, funtion(err,result){
    }); 
}

you may need to wait for each transaction to be mined

  • If I am using Web3.js, how would I use that loop ? Do I use eth_sendTransaction() with the params being multiple array elements of params as described in github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction and does it mean I have to individually apply gas to each transaction ? – thotheolh May 9 '18 at 8:54
  • I do not think this will work, the field "from" take only one address (20 bytes). If you loop through the list of addresses you will pay the gas for each transaction. Transfering ether is cheap though (2300 gas). As for how to do it on web3, is a regular loop and inside run the sendTransaction method indexing your array of addresses. let me know how it goes. – Jaime May 9 '18 at 9:24
  • So essentially if I want to pay to multiple addresses, I would effectively need to create a contract script and upload the contract script to the Ethereum network and then whenever I want to pay to multiple addresses, I would have to pay to the contract script I uploaded and it will do the payment to multiple addresses on my behalf ? – thotheolh May 9 '18 at 11:00
  • No, I updated the answer, take a look and let me know if it works for you. – Jaime May 9 '18 at 11:34
1

you can easily achieve this in ethereum also, by taking the multiple addresses in an array and using the send transaction in one go. You can refer to this How to send tokens to multiple addresses in one go

  • Does it require a specialized contract script to be deployed or is this an out-of-the-box capability that Ethereum presents ? – thotheolh May 9 '18 at 6:40
  • @thotheolh just specialized contract script. – Sumit Patel May 9 '18 at 7:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.