Usage
const {
data,
isLoading,
isError,
isSuccess,
error,
refetch,
fetchTransactionList,
} = useGetTransactionList({
query: {
page: 1,
limit: 10,
walletAddress: "0x...",
},
getBearerToken: getToken,
});
Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query.page | number | No | Page number (default: 1) |
query.limit | number | No | Results per page (default: 10) |
query.walletAddress | string | No | Filter by wallet address |
query.calledFunction | string | No | Filter by contract function name |
query.day | number | No | Filter by day (1–31) |
query.month | number | No | Filter by month (1–12) |
query.year | number | No | Filter by year |
getBearerToken | () => Promise<string> | Yes | Function returning the auth token |
queryOptions | UseQueryOptions | No | React Query options (e.g. staleTime, enabled) |
Return Value
| Property | Type | Description |
|---|---|---|
data | PaginatedResponse<Transaction> | undefined | Paginated transaction results |
isLoading | boolean | True while fetching |
isError | boolean | True if an error occurred |
isSuccess | boolean | True if the query succeeded |
error | Error | null | Error when isError is true |
refetch | () => void | Re-run the query |
fetchTransactionList | (input) => Promise<PaginatedResponse<Transaction>> | Imperatively fetch with custom params |
Example Implementation
import { useGetTransactionList } from "@chipi-stack/chipi-react";
import { useAuth } from "@clerk/nextjs";
import { useState } from "react";
export function TransactionList({ walletAddress }: { walletAddress: string }) {
const { getToken } = useAuth();
const [page, setPage] = useState(1);
const { data, isLoading, error } = useGetTransactionList({
query: {
page,
limit: 10,
walletAddress,
},
getBearerToken: getToken,
});
if (isLoading) return <p>Loading transactions...</p>;
if (error) return <p>Error: {error.message}</p>;
return (
<div>
<ul>
{data?.data.map((tx) => (
<li key={tx.id}>
{tx.transactionHash} — {tx.status}
</li>
))}
</ul>
<div>
<button onClick={() => setPage((p) => Math.max(1, p - 1))} disabled={page === 1}>
Previous
</button>
<span>Page {page}</span>
<button onClick={() => setPage((p) => p + 1)}>Next</button>
</div>
</div>
);
}
