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
- Node.js (v16.15+)
- Yarn or npm
- @solana/web3.js
- Basic JavaScript knowledge
- Familiarity with Solana transactions (recommended: How to Send a Transaction on Solana)
👉 Get started with Solana development
Step 1: Set Up Your Environment
Create a project directory and file:
mkdir get_sol_tx cd get_sol_tx echo > log.jsInstall dependencies:
yarn add @solana/web3.js # or npm install @solana/web3.jsIn
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:
- Required: Address to search (as a
PublicKey) - Optional:
{ before, after, limit }(maxlimit= 1,000)
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.jsStep 4: Parse Transaction Details
Enhance your query with getParsedTransactions to extract:
- Program interactions
- Account keys
- Metadata
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
- Solana’s
getSignaturesForAddressretrieves transaction history for any address. - Combine with
getParsedTransactionsfor deeper analysis. - QuickNode RPCs optimize speed and reliability.
Ready to build more? Subscribe to our newsletter for advanced guides! 🚀