I have a dapp that communicates with one contract address. I want users to submit data in the frontend and then the data will be transferred to backend, where an ethereum account will make and sign the transactions in order to send these data to the smart contract.
I am thinking will there be a problem if the same account has to send simultaneously many transaction to the same contract address?
What happens if one transaction is not mined? Will all the other fail, maybe because of nonce?
Do you think I could use one account in backend to handle all transactions because users are not aware of blockchain technology, so I don't want them to use a wallet.
1 Answer
Ethereum expects transactions sent from the same account to have the nonce field in increasing order without gaps. First transaction nonce is 0, next one is 1, then 2, etc.
If you sent many transactions you have to make sure that at no point a transaction will get stuck otherwise it will block all the following transactions.
You can use several accounts but eventually all of them may get blocked if you are not carefull.
-
So a good solution might be to have many accounts and each account should proceed to an another send only if the previous transaction is mined. Is my thinking correct? Also to be sure that is mined and won't have a nonce problem should I wait for many confirmation or I am sure that is mined when i receive the event on receipt? I am referring to events emitted from function eth.sendTransaction– kathiFeb 13, 2021 at 16:25
-
@kathi It depends on your particular use case. Ideally you have to check periodically that transactions were mined and if they are stuck or they cause an error try to fix the problem (gas too low => increase gas price, not enough funds => add ether to sender, etc). For example an exchange it is critical to have several confirmations so 30 minutes for confirmation is acceptable. For a coffee more than a couple of minutes is too much wait.– Ismael ♦Feb 13, 2021 at 19:23