When to use
- Anywhere (no AlphscanProvider required).
- When you need normalized events for a single transaction with loading/error and refetch.
Signature
UseTxNormalizedEventsOptions
Return value
Example
NormalizedEventsList).Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Transaction normalized events hook
function useTxNormalizedEvents(
transactionId: string | undefined,
options?: UseTxNormalizedEventsOptions
): {
data: TxNormalizedEventsResponse | null;
loading: boolean;
error: Error | null;
refetch: () => Promise<void>;
}
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | "https://api.alphscan.io" | API base URL. |
settings | Partial<AlphscanSettings> | — | Full settings (overrides baseUrl). |
enabled | boolean | true | If false, or transactionId falsy, no request. |
| Field | Type | Description |
|---|---|---|
data | TxNormalizedEventsResponse | null | { transaction_id, events } or null. |
loading | boolean | Request in progress. |
error | Error | null | Error if request failed. |
refetch | () => Promise<void> | Refetch events. |
import { useTxNormalizedEvents } from "@alphscan/sdk-react";
function TransactionEvents({ txId }: { txId: string | undefined }) {
const { data, loading, error, refetch } = useTxNormalizedEvents(txId, {
baseUrl: "https://api.alphscan.io",
apiKey: process.env.NEXT_PUBLIC_ALPHSCAN_API_KEY,
enabled: !!txId,
});
if (!txId) return <p>Enter a transaction ID</p>;
if (loading) return <p>Loading events…</p>;
if (error) return <p>Error: {error.message}</p>;
if (!data) return null;
return (
<div>
<p>Transaction {data.transaction_id}: {data.events.length} events</p>
<ul>
{data.events.map((e) => (
<li key={e.id}>{e.category} – {e.sub_kind}</li>
))}
</ul>
<button onClick={refetch}>Refetch</button>
</div>
);
}
NormalizedEventsList).