I want to add a loader to UI when there is a click on confirm transaction popup on metamask. When user clicks on confirm I want to show the loader until the transaction is confirmed. Is there a way to handle this?? Is there any event??

1 Answer 1


Ethers.js has a very simple solution for this question:

const provider = new ethers.providers.Web3Provider(window.ethereum);

let tx = await contract.method(...)
let txConfirm = await provider.getTransaction(tx.hash)
///perform operation only after "Confirm" is clicked in MetaMask

See docs on provider.getTransaction() here: https://docs.ethers.io/v5/single-page/#/v5/api/providers/provider/-%23-Provider-getTransactionReceipt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.