getTransactions
Fetches recent transactions for a given address with simple pagination support.
Usage
page.tsx
import { useConnection } from "@solana/wallet-adapter-react";
import { getTransactions } from "@okito/sdk";
const {connection} = useConnection();
const wallet = useWallet();
const options = {
limit: 5, //The number of transactions to fetch(Max 500)
before: "", //The signature to fetch from
until: "", //The signature to fetch to
commitment: "processed" //The commitment level to use
}
const transactionHistory = await getTransactions(connection,address,options)The default values of the params( limit = 20, commitment = “confirmed” ) will be used if not provided.
Capabilities
- Limit, before, until parameters for pagination
- Batching under the hood for efficient lookups
- Returns parsed transactions when available
Parameters
| Name | Type | Default |
|---|---|---|
connection | ConnectionSolana connection instance. | |
address | PublicKey | stringAddress to query. | |
options | TransactionHistoryOptionsLimit, before, until, commitment. | |
Response
| Name | Type | Default |
|---|---|---|
transactions? | ParsedTransactionWithMeta[]The transactions fetched | |
success | booleanWhether the transactions were fetched successfully | |
error? | stringThe error message if the transactions were not fetched successfully | |
signatures? | ConfirmedSignatureInfo[]The raw signatures fetched | |
hasMore? | booleanWhether there are more transactions to fetch | |
Types
ParsedTransactionWithMeta
| Name | Type | Default |
|---|---|---|
slot | numberThe slot during which the transaction was processed | |
transaction | ParsedTransactionThe transaction details | |
meta | ParsedTransactionMeta | nullThe metadata produced from the transaction | |
blockTime | number | nullThe unix timestamp of when the transaction was processed | |
version | TransactionVersion | undefined | |
ConfirmedSignatureInfo
| Name | Type | Default |
|---|---|---|
signature | stringThe signature of the transaction | |
slot | numberThe slot during which the transaction was processed | |
err | TransactionError | nullThe error produced from the transaction | |
memo | 'string' | nullThe memo associated with the transaction(if any) | |
blockTime | number | nullThe unix timestamp of when the transaction was processed | |
confirmationStatus | 'processed' | 'confirmed' | 'finalized' | undefinedThe confirmation status of the transaction | |
Last updated on