Hook for fetching and paginating through transaction history
UseGetTransactionHistoryReturnType
The hook returns all properties from React Query’s UseInfiniteQueryResult
with transaction history data. Here’s the detailed structure:
InfiniteData<GetTransactionHistoryReturn> | undefined
The paginated transaction history data containing multiple pages. Each page includes:
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 timestampPagination information object containing:
page
: Next page numbermore
: Whether more results exist in the next pagepageSize
: Number of results per page() => Promise<unknown>
Function to load the next page of transactions.
boolean
Boolean indicating if more transactions are available to load.
boolean
Loading state for the initial data fetch.
boolean
Loading state for any data fetch (initial or subsequent).
boolean
Loading state specifically for next page fetch.
Error | null
Any error that occurred during data fetching.
The hook accepts two parameters:
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 |
HooksOptions
Parameter | Type | Description |
---|---|---|
disabled | boolean | (Optional) Disable the query from automatically running |
retry | boolean | (Optional) Whether to retry failed queries |
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.