Retrieve the transaction history for a wallet address. This endpoint returns a paginated list of transactions including transfers, swaps, and other on-chain activity.
Transaction history is currently only supported for embedded wallets on Solana mainnet (network ID 101). Responses are cached for 5 seconds.
Parameters
| Parameter | Type | Required | Description |
|---|
| chainName | string | Yes | The blockchain type (SOL for Solana) |
| address | string | Yes | The wallet address to fetch transactions for |
| networkId | number | Yes | The network ID (101 for Solana mainnet) |
| limit | number | No | Number of transactions to return (1-100) |
| offset | string | No | Pagination offset from previous response |
Response
The response includes an array of transactions and a nextOffset for pagination:
| Property | Type | Description |
|---|
| transactions | array | List of transaction objects |
| nextOffset | string | Offset to fetch the next page of transactions |
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 |
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) |
import { dynamicClient } from "./dynamic";
interface Transaction {
transactionHash: string;
blockNumber: number;
transactionTimestamp: string;
fromAddress: string;
toAddress: string;
labels: string[];
blockExplorerUrls: string[];
assetTransfers: {
tokenAddress?: string;
fromAddress: string;
toAddress: string;
amount: number;
metadata?: {
name?: string;
symbol?: string;
decimals?: number;
imageUri?: string;
};
}[];
}
interface TransactionsResponse {
transactions: Transaction[];
nextOffset?: string;
}
export async function getWalletTransactions(
address: string,
networkId: number,
limit?: number,
offset?: string
): Promise<TransactionsResponse> {
const token = dynamicClient.auth.token;
if (!token) {
throw new Error("User not authenticated");
}
const params = new URLSearchParams({
networkId: networkId.toString(),
});
if (limit) params.append("limit", limit.toString());
if (offset) params.append("offset", offset);
const response = await fetch(
`https://app.dynamic.xyz/api/v0/sdk/${process.env.DYNAMIC_ENVIRONMENT_ID}/chains/SOL/transactions/${address}?${params}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
if (!response.ok) {
throw new Error(`Failed to fetch transactions: ${response.statusText}`);
}
return response.json();
}
// Usage example
async function fetchMyTransactions() {
const wallet = dynamicClient.wallets.primary;
if (!wallet) return;
const { transactions, nextOffset } = await getWalletTransactions(
wallet.address,
101, // Solana mainnet
10
);
console.log("Transactions:", transactions);
// Fetch next page if available
if (nextOffset) {
const nextPage = await getWalletTransactions(
wallet.address,
101,
10,
nextOffset
);
console.log("Next page:", nextPage.transactions);
}
}