useGetTransactionHistory
Hook for fetching and paginating through transaction history
Import
Usage
Return Type: UseGetTransactionHistoryReturnType
The hook returns all properties from React Query’s UseInfiniteQueryResult
with transaction history data. Here’s the detailed structure:
Properties
data
InfiniteData<GetTransactionHistoryReturn> | undefined
The paginated transaction history data containing multiple pages. Each page includes:
transactions
Array of transaction objects with the following properties:
txnHash
: Transaction hashblockNumber
: Block number where transaction was minedblockHash
: Hash of the blockchainId
: Chain ID where transaction occurredmetaTxnID
: Optional meta transaction IDtransfers
: Optional array of transaction transferstimestamp
: Transaction timestamp
page
Pagination information object containing:
page
: Next page numbermore
: Whether more results exist in the next pagepageSize
: Number of results per page
fetchNextPage
() => Promise<unknown>
Function to load the next page of transactions.
hasNextPage
boolean
Boolean indicating if more transactions are available to load.
isLoading
boolean
Loading state for the initial data fetch.
isFetching
boolean
Loading state for any data fetch (initial or subsequent).
isFetchingNextPage
boolean
Loading state specifically for next page fetch.
error
Error | null
Any error that occurred during data fetching.
Parameters
The hook accepts two parameters:
args: UseGetTransactionHistoryArgs
Parameter | Type | Description |
---|---|---|
chainId | number | The chain ID to fetch transactions from |
accountAddress | string | The address to fetch transaction history for |
contractAddress | string | (Optional) Filter transactions by contract address |
tokenId | string | (Optional) Filter transactions by token ID |
page | object | (Optional) Pagination configuration |
options: HooksOptions
Parameter | Type | Description |
---|---|---|
disabled | boolean | (Optional) Disable the query from automatically running |
retry | boolean | (Optional) Whether to retry failed queries |
Notes
This hook provides methods to fetch transaction history with support for infinite scrolling. It can filter transactions by contract address and token ID, making it useful for both general account history and specific asset history views.
The hook uses @tanstack/react-query
internally for data fetching and caching, with a stale time of 30 seconds.
Was this page helpful?