Solana Program Interface icon

Solana Program Interface

Fetch token balance changes for specific Solana program instructions with date or count limits

Overview

This node monitors and analyzes token balance changes for specific instructions within a given Solana program. It fetches recent transactions related to the specified program ID, filters them by instruction names, and provides detailed statistics on token movements and transaction counts. Users can limit the scope either by the number of transactions or by a date range, include native SOL balance changes, and sort results by various criteria.

Common scenarios:

  • Tracking token staking/unstaking activities in a DeFi protocol on Solana.
  • Monitoring transfers or other custom instructions of a Solana program.
  • Auditing token flow and volume for specific program instructions over time.

Practical example:
A user wants to monitor the "stake_usdc" and "unstake_usdc" instructions of a Solana program with public key GYe1hhxHhojNy5LfTddD79BdHCnsYC2dsD8KMrKn1se6. They want to analyze the last 20 transactions and see the largest token amount changes first, including any native SOL balance changes.

Properties

Name Meaning
Program ID The Solana program's public key to monitor (e.g., GYe1hhxHhojNy5LfTddD79BdHCnsYC2dsD8KMrKn1se6).
Instruction Names Comma-separated list of instruction names to filter (e.g., stake_usdc,unstake_usdc,transfer).
Limit Type How to limit the transactions analyzed:
- Limit by Number of Transactions
- Limit by Date Range
Transaction Count Limit Maximum number of recent transactions to analyze (valid when limiting by count). Range: 1-100.
Start Date Start date/time (UTC) for filtering transactions (valid when limiting by date range).
End Date End date/time (UTC) for filtering transactions (valid when limiting by date range).
Include SOL Changes Boolean flag to include native SOL balance changes in the results.
Minimum Amount Threshold Minimum token amount change (in smallest token unit) to include in results.
Sort Results How to sort the transaction results:
- Newest Transactions First
- Oldest Transactions First
- Largest Amount Changes First

Output

The node outputs a single JSON object containing:

  • summary: General summary including:

    • programId: The monitored program ID.
    • instructionNames: List of filtered instruction names.
    • totalTransactions: Number of transactions processed.
    • totalTokenMovements: Total count of token movements matching criteria.
  • instructions: An object keyed by instruction name, each containing:

    • stats: Statistics such as transaction count, total volume moved, average amount per transaction.
    • tokenMovements: Details per token mint including total volume, decimals, symbol (if known), and an array of individual transactions with metadata (transaction ID, slot, timestamp, amount moved, direction, involved accounts, fee, instruction index).
  • solChanges (optional): If enabled, includes an array of native SOL balance changes detected in the transactions, each with transaction ID and amount changed.

  • debug: Detailed debug information including:

    • Processed signatures count.
    • Instruction match counts.
    • Discriminator map used for instruction identification.
    • Array of parsed transactions with metadata about instructions, logs, token balances, etc.

If binary data is present in instructions, it is decoded and analyzed for discriminators but not outputted directly.

Dependencies

  • Requires connection to a Solana RPC endpoint URL provided via credentials.
  • Uses the @solana/web3.js library for blockchain interaction.
  • Uses @coral-xyz/anchor utilities for instruction discriminator calculation.
  • Uses bs58 for base58 decoding of instruction data.
  • Requires an API key credential for Solana RPC access configured in n8n.

Troubleshooting

  • Invalid program ID error: Occurs if the provided program ID is not a valid Solana public key. Verify the input format.
  • Failed to fetch signatures: Network or RPC issues may cause failure fetching transaction signatures. Check RPC URL and network connectivity.
  • Failed to fetch transactions: Similar to above, ensure the RPC endpoint is responsive and credentials are valid.
  • No matching instructions found: Ensure that the instruction names exactly match those emitted by the program, case-insensitive but must be correct.
  • Empty results: Could be due to no transactions in the specified date range or count limit, or minimum amount threshold filtering out all movements.
  • IDL not found warning: The node attempts to fetch the program's IDL to get instruction discriminators; if unavailable, it falls back to hashing heuristics which might be less accurate.

Links and References

Discussion