Skip to main content
Retrieves token transactions from the network with flexible filtering options for the SparkWallet.

Method Signature

async queryTokenTransactions({
  sparkAddresses,
  ownerPublicKeys,
  issuerPublicKeys,
  tokenTransactionHashes,
  tokenIdentifiers,
  outputIds,
  order,
  pageSize,
  offset,
}: {
  sparkAddresses?: string[];
  ownerPublicKeys?: string[]; // deprecated, use sparkAddresses
  issuerPublicKeys?: string[];
  tokenTransactionHashes?: string[];
  tokenIdentifiers?: string[];
  outputIds?: string[];
  order?: "asc" | "desc";
  pageSize?: number;
  offset?: number;
}): Promise<QueryTokenTransactionsResponse>

Parameters

Filter Constraint: You can only specify one filter type per query. The parameters are mutually exclusive - use sparkAddresses OR ownerPublicKeys OR issuerPublicKeys OR tokenTransactionHashes OR tokenIdentifiers OR outputIds, but not multiple types together.
sparkAddresses
string[]
Array of Spark addresses to filter by (recommended)
ownerPublicKeys
string[]
Array of owner public keys to filter by (deprecated, use sparkAddresses)
issuerPublicKeys
string[]
Array of issuer public keys to filter by
tokenTransactionHashes
string[]
Array of token transaction hashes to filter by
tokenIdentifiers
string[]
Array of Bech32m token identifiers to filter by
outputIds
string[]
Array of output IDs to filter by
order
string
Sort order: "asc" or "desc" (defaults to "desc")
pageSize
number
Number of results per page (defaults to 50)
offset
number
Pagination offset (defaults to 0)

Returns

response
QueryTokenTransactionsResponse
required
Token transactions response object

Example

// Query all token transactions
const transactions = await wallet.queryTokenTransactions({});

// Query transactions for specific tokens with pagination
const tokenTransactions = await wallet.queryTokenTransactions({
  tokenIdentifiers: ["btkn1..."],
  order: "desc",
  pageSize: 20,
  offset: 0
});

// Query transactions for specific Spark addresses
const addressTransactions = await wallet.queryTokenTransactions({
  sparkAddresses: ["spark1..."]
});
Getting the sender address: Token transaction outputs only show the recipient. To get the sender’s address for an incoming transfer, query the previous transaction using the prevTokenTransactionHash from the input’s OutputToSpend.