Skip to content

Components

Transaction Toast

Follow a transaction in a toast, from pending to confirmed or reverted.

Follow a transaction without keeping its UI on screen. One toast goes from “Transaction pending” to “Transaction confirmed” or “Transaction reverted”, with a link to the explorer. Built on Sonner.

Connect the Demo Wallet and send to see it.

Terminal window
npx shadcn@latest add @0xui/transaction-toast

This also installs the shadcn sonner component. Mount its <Toaster /> once, near the root of your app:

import { Toaster } from "@/components/ui/sonner";
<Web3Provider>
<App />
<Toaster />
</Web3Provider>;
import { useTransactionToast } from "@/components/transaction-toast";
const toastTransaction = useTransactionToast();
<TransactionButton
transaction={tx}
onSubmitted={(hash) => toastTransaction(hash, { description: "Send 0.01 ETH" })}
hideStatus
>
Send
</TransactionButton>;

It works with any hash, including ones from your own writeContract calls.

Option Type Description
chainId number Chain the transaction is on. Defaults to the current chain.
description ReactNode What the transaction does. Shown in every state.
titles { pending?, success?, reverted?, error? } Override the headings.
onConfirmed (receipt) => void Called when mined successfully.

The pending toast stays until the transaction settles. The confirmed toast stays 6 seconds, and the reverted or error toast 10 seconds.