[Ethereum] Sending multiple transactions in the same block with incremented nonces

javascriptkovan

I need to send 0.1 ETH to 10 unique addresses from the same address at the same time. I am manually incrementing each transaction's nonce, and the transactions are sent successfully.

However, each transaction is entered into a new block. For example, transaction A in block 1, B in 2, C in 3, and so on. The problem is that this isn't scalable across n transactions, because I'd have to wait for n blocks to confirm.

Is there a proper way to batch-send ETH so that the collective of transactions confirms as quickly as possible?

Edit: This has only been tested on Kovan. Even with Kovan's 4 second block time, shouldn't transactions sent at the exact same time be included in the same block?

Best Answer

You can write a solidity contract with one method that receives the addresses and the amounts to transfer, and performs the corresponding transfers.

Then you achieve your objective in a single transaction.

For security reasons I recommend to extend the Ownable contract and use the onlyOwner() modifier:

https://docs.openzeppelin.com/contracts/4.x/api/access#Ownable

:)

Related Topic