Skip to main content
POST
/
getTransactionWithCompressionInfo
cURL
curl --request POST \
  --url 'https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E%2FgetTransactionWithCompressionInfo' \
  --header 'Content-Type: application/json' \
  --data '
{
  "id": "test-account",
  "jsonrpc": "2.0",
  "method": "getTransactionWithCompressionInfo",
  "params": {
    "signature": "5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c"
  }
}
'
{
  "id": "test-account",
  "jsonrpc": "2.0",
  "error": {
    "code": 123,
    "message": "<string>"
  },
  "result": {
    "compression_info": {
      "closedAccounts": [
        {
          "account": {
            "hash": "11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP",
            "lamports": 100,
            "leafIndex": 100,
            "owner": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "slotCreated": 100,
            "tree": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "address": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "data": {
              "data": "SGVsbG8sIFdvcmxkIQ==",
              "dataHash": "11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP",
              "discriminator": 100
            },
            "seq": 100
          },
          "optionalTokenData": {
            "amount": 100,
            "mint": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "owner": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "state": "initialized",
            "delegate": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "tlv": "SGVsbG8sIFdvcmxkIQ=="
          }
        }
      ],
      "openedAccounts": [
        {
          "account": {
            "hash": "11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP",
            "lamports": 100,
            "leafIndex": 100,
            "owner": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "slotCreated": 100,
            "tree": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "address": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "data": {
              "data": "SGVsbG8sIFdvcmxkIQ==",
              "dataHash": "11111112cMQwSC9qirWGjZM6gLGwW69X22mqwLLGP",
              "discriminator": 100
            },
            "seq": 100
          },
          "optionalTokenData": {
            "amount": 100,
            "mint": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "owner": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "state": "initialized",
            "delegate": "111111131h1vYVSYuKP6AhS86fbRdMw9XHiZAvAaj",
            "tlv": "SGVsbG8sIFdvcmxkIQ=="
          }
        }
      ]
    },
    "transaction": {}
  }
}
ThegetTransactionWithCompressionInfo RPC method returns transaction data along with compression information showing which compressed accounts were opened (created) and closed (consumed) during the transaction. This method helps with transaction analysis, account lifecycle tracking, and debugging of compression operations.
You can test this method via the OpenAPI example or custom examples below.
Common Use Cases
  • Transaction Analysis: Understand what compressed accounts were affected by a transaction
  • Account Lifecycle Tracking: Monitor when compressed accounts are created and consumed
  • Debugging: Identify which accounts changed during failed or unexpected transactions
  • Audit Trails: Track compressed account state changes for compliance
Parameters
  1. signature (string, required): Base58-encoded transaction signature to query compression information for.
Note: Only transactions involving compressed accounts will return compression data. Regular Solana transactions return null. Response The response contains compression information and transaction data, or null if transaction not found:
  • compressionInfo (object): Contains details about compressed account changes
    • closedAccounts (array): Compressed accounts consumed (spent) in this transaction
      • account (object): Complete compressed account data with merkle context
      • maybeTokenData (object | null): Token data if this is a compressed token account
    • openedAccounts (array): New compressed accounts created in this transaction
      • account (object): Complete compressed account data with merkle context
      • maybeTokenData (object | null): Token data if this is a compressed token account
    • preTokenBalances (array, optional): Token balances before transaction
      • owner (PublicKey): Public key of token account owner
      • mint (PublicKey): Public key of token mint
      • amount (BN): Token amount as BN object
    • postTokenBalances (array, optional): Token balances after transaction
      • owner (PublicKey): Public key of token account owner
      • mint (PublicKey): Public key of token mint
      • amount (BN): Token amount as BN object
  • transaction (object): Standard Solana transaction data
Developer Tips
  • Compression-only: This method only works with transactions that involve compressed accounts
  • Real signatures required: Use actual transaction signatures from compression operations
  • Account lifecycle: opened = created, closed = consumed/spent in the transaction
  • Token data: maybeTokenData is null for regular compressed accounts, populated for token accounts
  • Balance tracking: Use pre/postTokenBalances for detailed token amount changes
  • State analysis: Compare opened vs closed accounts to understand transaction effects
Troubleshooting
Invalid or non-existent transaction signatureVerify the signature format and check transaction existence:
const result = await connection.getTransactionWithCompressionInfo(signature);

if (!result) {
    console.log('Transaction not found or contains no compression operations');
}
Transaction exists but has no compression dataThis method only returns data for transactions involving compressed accounts:
const result = await connection.getTransactionWithCompressionInfo(signature);

if (!result) {
    console.log('Transaction does not involve compressed accounts');
    console.log('Use regular getTransaction for non-compression transactions');
}
Transaction has compression info but no account changes shownSome compression operations may not create/consume accounts:
const { compressionInfo } = result;

if (compressionInfo.openedAccounts.length === 0 &&
    compressionInfo.closedAccounts.length === 0) {
    console.log('Compression transaction with no visible account changes');
    console.log('May be a proof verification or state update operation');
}
Examples The below examples work - just make sure you installed the dependencies.
npm install @lightprotocol/stateless.js
Example: Analyze Transaction
import { createRpc, Rpc, CompressedTransaction } from '@lightprotocol/stateless.js';

const rpc: Rpc = createRpc(
  'https://devnet.helius-rpc.com/?api-key=YOUR_API_KEY',
  'https://devnet.helius-rpc.com/?api-key=YOUR_API_KEY'
);

async function analyzeTransactionCompression(): Promise<void> {
    const signature: string = 'TRANSACTION_SIGNATURE_HERE';

    const result: CompressedTransaction | null =
        await rpc.getTransactionWithCompressionInfo(signature);

    if (!result) {
        console.log('Transaction not found or has no compression info');
        return;
    }

    const { compressionInfo } = result;

    console.log('Transaction Compression Summary:', {
        openedCount: compressionInfo.openedAccounts.length,
        closedCount: compressionInfo.closedAccounts.length,
        hasTokenBalances: !!(compressionInfo.preTokenBalances || compressionInfo.postTokenBalances)
    });

    // Type-safe account analysis
    compressionInfo.closedAccounts.forEach((entry, index) => {
        console.log(\`Closed Account ${index + 1}:\`, {
            hash: entry.account.hash.toString(),
            lamports: entry.account.lamports.toString(),
            hasTokenData: !!entry.maybeTokenData
        });
    });

    compressionInfo.openedAccounts.forEach((entry, index) => {
        console.log(\`Opened Account ${index + 1}:\`, {
            hash: entry.account.hash.toString(),
            lamports: entry.account.lamports.toString(),
            hasTokenData: !!entry.maybeTokenData
        });
    });
}

analyzeTransactionCompression();
Example: Track Token Balance Changes
async function trackTokenBalanceChanges(): Promise<void> {
    const connection = createRpc(
        'https://devnet.helius-rpc.com/?api-key=YOUR_API_KEY',
        'https://devnet.helius-rpc.com/?api-key=YOUR_API_KEY'
    );

    const signature = 'TOKEN_TRANSACTION_SIGNATURE_HERE';

    const result = await connection.getTransactionWithCompressionInfo(signature);

    if (!result) {
        console.log('Transaction not found');
        return;
    }

    const { compressionInfo } = result;

    // Analyze token balance changes if available
    if (compressionInfo.preTokenBalances && compressionInfo.postTokenBalances) {
        console.log('Token Balance Changes:');

        compressionInfo.preTokenBalances.forEach((preBalance, index) => {
            const postBalance = compressionInfo.postTokenBalances![index];
            const change = postBalance.amount.sub(preBalance.amount);

            if (!change.isZero()) {
                console.log(\`  Owner: ${preBalance.owner.toBase58()}\`);
                console.log(\`  Mint: ${preBalance.mint.toBase58()}\`);
                console.log(\`  Change: ${change.toString()}\`);
            }
        });
    } else {
        console.log('No token balance data available for this transaction');
    }

    // Analyze token accounts in opened/closed arrays
    const tokenAccountsOpened = compressionInfo.openedAccounts.filter(
        entry => entry.maybeTokenData !== null
    );

    const tokenAccountsClosed = compressionInfo.closedAccounts.filter(
        entry => entry.maybeTokenData !== null
    );

    console.log(\`Token accounts opened: ${tokenAccountsOpened.length}\`);
    console.log(\`Token accounts closed: ${tokenAccountsClosed.length}\`);

    return {
        tokenAccountsOpened: tokenAccountsOpened.length,
        tokenAccountsClosed: tokenAccountsClosed.length
    };
}

trackTokenBalanceChanges();

Body

application/json
id
enum<string>
required

An ID to identify the request.

Available options:
test-account
jsonrpc
enum<string>
required

The version of the JSON-RPC protocol.

Available options:
2.0
method
enum<string>
required

The name of the method to invoke.

Available options:
getTransactionWithCompressionInfo
params
object
required

Response

id
enum<string>
required

An ID to identify the response.

Available options:
test-account
jsonrpc
enum<string>
required

The version of the JSON-RPC protocol.

Available options:
2.0
error
object
result
object

A Solana transaction with additional compression information