useUserTransactions
Hook for fetching user transactions without activities with support for pagination. If no address is provided, it defaults to the connected account.
Compared with useAccountTransactions which fetches transactions with activities related to a specific account, this query will not fetch transactions related to the account, but must be directly specified by the sender address.
Usage
import React from "react";
import { useUserTransactions } from "@aptos-labs/react";
export default function App() {
const { data: transactions } = useUserTransactions();
return (
<div>
<h2>User Transactions:</h2>
{transactions?.pages.map((page, i) => (
<React.Fragment key={i}>
{page.transactions.map((tx) => (
<div key={tx.hash}>{tx.hash}</div>
))}
</React.Fragment>
))}
</div>
);
}
Parameters
Return Type
Name | Type | Default |
---|---|---|
data | InfiniteData<FetchUserTransactionsResult, unknown> | undefined The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. The last successfully resolved data for the query. | |
error | Error | null The error object for the query, if an error was thrown.
| |
isError | boolean A derived boolean from the
| |
isPending | boolean Will be | |
isLoading | boolean Is
| |
isLoadingError | boolean Will be | |
isRefetchError | boolean Will be | |
isSuccess | boolean A derived boolean from the
| |
isPlaceholderData | boolean Will be | |
status | "error" | "success" | "pending" The status of the query.
| |
fetchNextPage | (options?: FetchNextPageOptions | undefined) => Promise<InfiniteQueryObserverResult<InfiniteData<FetchUserTransactionsResult, unknown>, Error>> This function allows you to fetch the next “page” of results. | |
fetchPreviousPage | (options?: FetchPreviousPageOptions | undefined) => Promise<InfiniteQueryObserverResult<InfiniteData<FetchUserTransactionsResult, unknown>, Error>> This function allows you to fetch the previous “page” of results. | |
hasNextPage | boolean Will be | |
hasPreviousPage | boolean Will be | |
isFetchNextPageError | boolean Will be | |
isFetchingNextPage | boolean Will be | |
isFetchPreviousPageError | boolean Will be | |
isFetchingPreviousPage | boolean Will be | |
dataUpdatedAt | number The timestamp for when the query most recently returned the | |
errorUpdatedAt | number The timestamp for when the query most recently returned the | |
failureCount | number The failure count for the query.
| |
failureReason | Error | null The failure reason for the query retry.
| |
errorUpdateCount | number The sum of all errors. | |
isFetched | boolean Will be | |
isFetchedAfterMount | boolean Will be
| |
isFetching | boolean A derived boolean from the
| |
isInitialLoading | boolean | |
isPaused | boolean A derived boolean from the
| |
isRefetching | boolean Is
| |
isStale | boolean Will be | |
refetch | (options?: RefetchOptions | undefined) => Promise<QueryObserverResult<InfiniteData<FetchUserTransactionsResult, unknown>, Error>> A function to manually refetch the query. | |
fetchStatus | FetchStatus The fetch status of the query.
| |
promise | Promise<InfiniteData<FetchUserTransactionsResult, unknown>> A stable promise that will be resolved with the data of the query.
Requires the |