You can retrieve the transaction history for a wallet address by calling the getTransactionHistory function.
This function fetches the transaction history for a specified wallet address and chain, returning a list of transactions along with a nextOffset for pagination.
Transaction history is currently only supported for embedded wallets on Solana mainnet (network ID 101). Responses are cached for 5 seconds.
Usage
import { getTransactionHistory } from '@dynamic-labs/client';
const { transactions, nextOffset } = await getTransactionHistory({
address: 'CKEAuq1E7hUcrjDcu1xP6nax3YBvEhhq7qaCzDUkPNer',
chain: 'SOL',
networkId: 101, // Solana mainnet
limit: 10,
});
console.log(transactions);
// Fetch next page if available
if (nextOffset) {
const nextPage = await getTransactionHistory({
address: 'CKEAuq1E7hUcrjDcu1xP6nax3YBvEhhq7qaCzDUkPNer',
chain: 'SOL',
networkId: 101,
limit: 10,
offset: nextOffset,
});
}
Parameters
| Parameter | Type | Required | Description |
|---|
address | String | Yes | The wallet address to fetch transactions for |
chain | Chain | Yes | The chain to query transactions for (e.g., SOL) |
networkId | Number | Yes | The network ID (e.g., 101 for Solana mainnet) |
limit | Number | No | Maximum number of transactions to return |
offset | String | No | Pagination offset from previous response |
Response
The function returns a Promise that resolves to an object containing:
| Property | Type | Description |
|---|
transactions | Array | List of transaction objects |
nextOffset | String | Offset to fetch the next page of transactions |
Transaction object
Each transaction object contains:
| Property | Type | Description |
|---|
transactionHash | String | The transaction hash |
blockNumber | Number | Block number of the transaction |
transactionTimestamp | String | ISO 8601 timestamp of the transaction |
blockHash | String | Hash of the block containing the transaction |
blockExplorerUrls | String[] | URLs to view the transaction on block explorers |
fromAddress | String | Sender address |
toAddress | String | Recipient address |
labels | String[] | Transaction type labels: sent, receive, or swap |
assetTransfers | Array | Details of assets transferred in the transaction |
chainName | String | The blockchain type |
networkId | Number | The network ID |
Asset transfer object
Each asset transfer contains:
| Property | Type | Description |
|---|
tokenAddress | String | Contract address of the token (empty for native tokens) |
fromAddress | String | Sender address for this transfer |
toAddress | String | Recipient address for this transfer |
amount | Number | Amount transferred |
metadata | Object | Token metadata (name, symbol, decimals, imageUri) |