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.