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>