Skip to main content
Retrieve the transaction history for a wallet address. This endpoint returns a paginated list of transactions including transfers, swaps, and other on-chain activity.
Using the JavaScript SDK? See getTransactionHistory for a simpler approach.
Transaction history is currently only supported for embedded wallets on Solana mainnet (network ID 101) and Solana devnet (network ID 103). Responses are cached for 5 seconds.For devnet, we only retain 2 weeks of transaction history.

Parameters

ParameterTypeRequiredDescription
chainNamestringYesThe blockchain type (SOL for Solana)
addressstringYesThe wallet address to fetch transactions for
networkIdnumberYesThe network ID (101 for Solana mainnet)
limitnumberNoNumber of transactions to return (1-100)
offsetstringNoPagination offset from previous response

Response

The response includes an array of transactions and a nextOffset for pagination:
PropertyTypeDescription
transactionsarrayList of transaction objects
nextOffsetstringOffset to fetch the next page of transactions
Each transaction object contains:
PropertyTypeDescription
transactionHashstringThe transaction hash
blockNumbernumberBlock number of the transaction
transactionTimestampstringISO 8601 timestamp of the transaction
blockHashstringHash of the block containing the transaction
blockExplorerUrlsstring[]URLs to view the transaction on block explorers
fromAddressstringSender address
toAddressstringRecipient address
labelsstring[]Transaction type labels: sent, receive, or swap
assetTransfersarrayDetails of assets transferred in the transaction
chainNamestringThe blockchain type
networkIdnumberThe network ID
transactionTypestringEnhanced transaction type (e.g., TRANSFER, SWAP). Only present for Solana transactions.
sourcestringThe program or protocol that originated the transaction (e.g., SYSTEM_PROGRAM, JUPITER). Only present for Solana transactions.
descriptionstringHuman-readable description of the transaction. Only present for Solana transactions.
spambooleanWhether the transaction is likely spam (e.g., dust attacks). Only present for Solana transactions.
Each asset transfer contains:
PropertyTypeDescription
tokenAddressstringContract address of the token (empty for native tokens)
fromAddressstringSender address for this transfer
toAddressstringRecipient address for this transfer
amountnumberAmount transferred in the token’s smallest unit (e.g., lamports for SOL, raw units for SPL tokens). Use metadata.decimals to convert to a human-readable value.
metadataobjectToken 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);
      }
    }