I'm struggling to implement the functionality which sends multiple transactions using the same address. here the from address is same but the to addresses are different. When I did research on this, I found that there are two ways to implement the approach -
Perform all transactions parallelly by incrementing the nonce one after one. Call getTransactionCount method one time and increment its count on all the subsequent transactions.
Implement the queue, In which the second transaction does not proceed until the first transaction mined.
When I analyzed the above two approach, I got to know about some issues -
In Approach 1, There may be possible that If one transaction will fail, So all the transaction after that nonce would become fail. But how does the metamask manage such type of cases? because the metamask also do the same thing and we can able to perform transactions one after one.
In Approach 2, In the queue process, one transaction depends on the prior transaction and it not initiated until first gets completed.
As I dig more into the approach, I found that the best approach would be the second one. (queue process)
But I stuck on the following cases while implementing the 2nd approach -
Because we don't know the exact time of the transaction mined in the block, how to decide the time interval to check whether the transaction block is mined or not. (I know that we use the ropsten.etherscan to check the transaction status)
If we give time Interval 15 sec. then it might be possible that transaction not mined in 1 hour and it keeps busy the server to send the request.
There might be such case, where one transaction could not mine until 2-3 days, due to some reasons. In this case what we need to do for overwriting that transaction. What will be the best approach to handle this?