How to Get Transaction Logs on Solana: A Step-by-Step Guide

·

Overview

Ever needed to pull all transactions associated with a Solana wallet? Whether you're tracking mint transactions from a Candy Machine or reviewing an NFT's history, Solana's getSignaturesForAddress method simplifies transaction logging. This guide walks you through building a script to query any Solana address (wallet, program ID, token mint, etc.) and retrieve its full transaction history.

Prerequisites

👉 Get started with Solana development


Step 1: Set Up Your Environment

  1. Create a project directory and file:

    mkdir get_sol_tx
    cd get_sol_tx
    echo > log.js
  2. Install dependencies:

    yarn add @solana/web3.js  # or npm install @solana/web3.js
  3. In log.js, import the Solana Web3 library and define your search address:

    const solanaWeb3 = require('@solana/web3.js');
    const searchAddress = 'vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg'; // Example address

Step 2: Connect to a Solana RPC Endpoint

Use a QuickNode endpoint for faster performance (free trial available):

const endpoint = 'https://example.solana-devnet.quiknode.pro/000000/';
const solanaConnection = new solanaWeb3.Connection(endpoint);

Step 3: Query Transactions with getSignaturesForAddress

This method accepts:

const getTransactions = async (address, numTx) => {
  const pubKey = new solanaWeb3.PublicKey(address);
  const transactionList = await solanaConnection.getSignaturesForAddress(pubKey, { limit: numTx });
  
  transactionList.forEach((transaction, i) => {
    const date = new Date(transaction.blockTime * 1000);
    console.log(`Transaction No: ${i + 1}`);
    console.log(`Signature: ${transaction.signature}`);
    console.log(`Time: ${date}`);
    console.log(`Status: ${transaction.confirmationStatus}`);
    console.log("-".repeat(20));
  });
};

Run the script:

node log.js

Step 4: Parse Transaction Details

Enhance your query with getParsedTransactions to extract:

const signatureList = transactionList.map(tx => tx.signature);
const transactionDetails = await solanaConnection.getParsedTransactions(signatureList, { maxSupportedTransactionVersion: 0 });

transactionDetails.forEach((detail, i) => {
  const instructions = detail.transaction.message.instructions;
  instructions.forEach((instruction, n) => {
    console.log(`--- Program ${n + 1}: ${instruction.programId.toString()}`);
  });
});

Step 5: Validate Results

Compare your output with Solana Explorer:
👉 Solana Devnet Explorer


FAQs

1. How do I handle large transaction volumes?

Use pagination with before/after parameters to chunk requests.

2. Can I query transactions for NFTs?

Yes! Use the NFT's mint address as the search parameter.

3. What’s the maximum limit for getSignaturesForAddress?

1,000 transactions per request.

4. How do I filter failed transactions?

Check the err field in ConfirmedSignatureInfo.

👉 Explore Solana's full API documentation


Key Takeaways

Ready to build more? Subscribe to our newsletter for advanced guides! 🚀