Execute concurrent transaction from single or multiple accounts

Hi,
I have a use case where I want to levy transaction fees of users to the admin. I was able to do this to the extent where only a single user is making a transaction, However, if there are multiple users making transactions at the same time then it fails due to the same nonce with the error “Returned error: replacement transaction underpriced.”

I was thinking of having multiple accounts to perform the user’s transactions by having a load balancer, but I am really concerned if that would be the right way of approaching the solution.

What approach would be an optimal one to resolve this issue?

you can use a queue, where you add the requests from users and after that make the transactions in a sequence so that you don’t reuse the same nonce twice

Thank you for your response @cryptokid, I really appreciate it.
As I will be processing requests one by one from the queue, won’t that make the overall transaction speed low?
Is there any approach through which I can decrease the wait time for transaction execution as well?

you don’t have to necessarily wait for transaction to complete, if you know that it will succeed at the end

Hey @cryptokid
Thanks for your help. After research, I found a package @ethersproject/experimental that does the job of handling the concurrent transactions.

1 Like