When I use Web3.js with MetaMask to pay tokens, I first approve the token spending. However, if I confirm the send transaction request in the MetaMask popup without closing the approval success popup, I receive the following MetaMask error:
Error:
“Could not coalesce error (error={ “code”: -32603, “message”: “Request of type ‘smartTransaction:showSmartTransactionStatusPage’ already pending for origin chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn. Please wait.” }…)”
Despite this error, the transaction is actually confirmed successfully.
I want to get the transaction hash when this error occurs or revert the transaction with an alert.
I am currently building a crypto-related service, and I’ve encountered an issue that I believe some users may also face.
In my code, I first call the approve function of a smart contract. Once the approval transaction is successful, I then call the pay function.
However, if I confirm the pay transaction in MetaMask without closing the success modal of the approve transaction like above screenshots, an error occurs.
In this situation, MetaMask displays a failed transaction alert due to the pending transaction modal, but I believe the transaction should stop at that point instead of continuing.
Right now, my code execution halts when the first failed transaction occurs, which prevents me from retrieving the transaction results and hash after confirming the transaction.
I found this Stack Overflow post, but no solution was found.
…/questions/79435935/receiving-an-error-after-a-toast-message-although-the-transaction-is-done-succe
I would like to know how to retrieve the transaction result even if this error occurs or prevent the transaction from being confirmed in such cases.