I have a website, I need to create a payment button that allows the buyer to complete their email and that when I receive the payment in my MetaMask, a receipt of that payment will be sent to the email. its that possible?
1 Like
Hello, yes.
For example, you can use the Promise and send the hash to the user by email after the transaction is completed ( resolve the Promise ).
import { toast } from "react-toastify";
const customToast = (promise) => {
toast.promise(promise, {
pending: {
render() {
return <div>Waiting to...</div>;
},
},
success: {
render({ data }) {
return (
<div>
// data.transactionHash
</div>
);
}
},
error: {
render({ data }) {
return (
<div className="p-3">
// data.message
</div>
);
}
}
})
}
const sendTransaction = async (priceInWei) => {
try {
// interaction with web3
} catch (error) {
throw new Error(error.message);
} finally {
// send email after tx is success
}
};
<Button onClick={() => customToast(sendTransaction(price)) } >
Send
</Button>
2 Likes
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.