1

I have seen this discussed here but didn't get a satisfactory answer. What is the recommended way to send ether to multiple recipients?

One way that I have thought of is follows:

Deploy a smart contract that accepts ether from any account along with a list of recipient addresses+amounts.

The contract splits the funds to the various accounts. However, I have some concerns:

What if the recipient is a contract that has some weird code in its fallback function? There may be other security issues too.

What is the best way to do this? Is there a well tested smart contract that takes care of the border cases that I can reuse?

If it helps, I am using Web3j and Ethereumj to interact with the blockchain.

EDIT: An alternate way is to send multiple transactions and not use a contract at all. Is there any economical benefit of the contract? It seems that even via a contract, Ethers are sent to multiple addresses and would incur linearly increasing cost. Is this correct? Are the costs similar?

2

You can test to see if an address is a regular account and not a contract account by using eth.getCode(address) (whatever the equivalent is in your api). If there is no code, its just a normal account and you can send ether to your heart's delight! If there is code then things get a bit trickier.

I can't really give you an answer for 'border cases' until I know the purpose for why you are sending ether to multiple accounts from a contract.

You could easily write an off-chain function that simply sends ether to each account without having to deploy a contract.

If you want that contract in place because it updates new accounts being added to the contract storage then I can't see any other edge cases. Whatever function in the contract adds new accounts to storage will just need to check if there is code at the account address before adding it.

  • I want to create an Ether wallet that allows sending to multiple recipients. Just a regular wallet to store Ethers. Nothing fancy. However, I want to allow sending to contract addresses as well, otherwise the wallet is not very useful. – Jus12 Oct 24 '17 at 15:49
  • K well then just check for contract code and it should be easy to implement. Just store some ethers in the contract and then include a function that splits the ether up and sends it out. In the case of it being a contract I don't think its your responsibility to check that though. Whoever deployed the contract you are sending to should have proper fallback function in place so ethers don't get thrown away. – jojeyh Oct 24 '17 at 15:51
  • But has no one made a reusable contract for that? Seems to be a pretty common requirement. – Jus12 Oct 24 '17 at 15:53
  • Haven't seen one – jojeyh Oct 24 '17 at 15:55
1

You can use this open-source tool - http://bulktokensending.online It allows generating ETH addresses also. The source is here https://github.com/bulktokensending/bulktokensending

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.