TransactionButton
A button component that handles blockchain transaction submission with built-in status tracking and notifications.
TransactionButton
The TransactionButton component handles individual transaction submission with built-in status tracking and notifications.
Usage
Props
Prop | Type | Default | Description |
---|---|---|---|
chain_id | number | - | Chain ID for the transaction |
title | string | - | Transaction title |
description | string | - | Transaction description |
data | any | - | Transaction data |
onTransactionSent | (timestamp: number) => void | - | Called when transaction is sent |
onTransactionConfirmed | (receipt: any) => void | - | Called when transaction is confirmed |
className | string | - | Additional CSS classes |
Features
- Automatic wallet connection handling
- Network switching support
- Transaction status tracking
- Toast notifications with explorer links
- Loading states and error handling
Examples
Basic Transaction
With Custom Styling
Component States
-
Not Connected
- Shows "Connect Wallet" button
- Handles wallet connection
-
Wrong Network
- Shows "Wrong Network" button
- Handles network switching
-
Ready
- Shows transaction button
- Enables transaction submission
-
Processing
- Shows loading indicator
- Tracks transaction status
Notifications
The component provides toast notifications for:
- Transaction sent
- Transaction confirmed
- Transaction failed
Each notification includes:
- Timestamp
- Transaction explorer link
- Appropriate styling
Edit on GitHub
Last updated on