The following function happens when a user clicks a "withdraw" button in my dapp:

const canUserWithdraw = async () => {
            if (b <= a) {
                alert("You can withdraw today");
                contract.faucet(account[0], withdrawalAmount);
                await confirm();
            } else if (b > a) {
                alert("Insufficient funds");
            } else {
                alert("Please enter an amount you'd like to withdraw");
        await canUserWithdraw();

Then after they click confirm in metamask:

const confirm = async () => {
            await contract.on("confirmation", () => console.log("Transfer"));

At the moment all I get is two console logs of "Transfer" - how can I process the second log (which means the transfer has been successful) so then I can update my DB?

Something like a loading page would be a good solution.

3 Answers 3


I do not think wallet will post event for confirmations, that are just increased block numbers after the transaction was initially mine. If you want to do this, you need to count blocks yourself over the JSON-RPC AI.

Furthermore for dApp us case, there is no need to wait confirmations at all, because there is no centralised element and mixing user funds involved.


Checkout web3.eth.getTransactionReceipt()



You can use an websocket to verify:

const websocket = new ethers.WebSocketProvider("YOUR_WSS_URL")

websocket.on("block", () => {
 const receipt = ethers.getTransactionReceipt(TX_HASH)
 if(recepit.status === 0){
} if(receipt.status === 1){

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.