cURL
curl --request POST \
--url 'https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo' \
--header 'Content-Type: application/json' \
--data '
{
"id": "test-account",
"jsonrpc": "2.0",
"method": "getTransactionWithCompressionInfo",
"params": {
"signature": "5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c"
}
}
'import requests
url = "https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo"
payload = {
"id": "test-account",
"jsonrpc": "2.0",
"method": "getTransactionWithCompressionInfo",
"params": { "signature": "5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c" }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: 'test-account',
jsonrpc: '2.0',
method: 'getTransactionWithCompressionInfo',
params: {signature: '5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c'}
})
};
fetch('https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 'test-account',
'jsonrpc' => '2.0',
'method' => 'getTransactionWithCompressionInfo',
'params' => [
'signature' => '5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo"
payload := strings.NewReader("{\n \"id\": \"test-account\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"getTransactionWithCompressionInfo\",\n \"params\": {\n \"signature\": \"5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"test-account\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"getTransactionWithCompressionInfo\",\n \"params\": {\n \"signature\": \"5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"test-account\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"getTransactionWithCompressionInfo\",\n \"params\": {\n \"signature\": \"5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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": {}
}
}{
"error": {
"code": 123,
"message": "<string>"
},
"id": "<string>",
"jsonrpc": "<string>"
}{
"error": {
"code": 123,
"message": "<string>"
},
"id": "<string>",
"jsonrpc": "<string>"
}JSON RPC Methods
Gettransactionwithcompressioninfo
Retrieve the transaction data for the transaction with the given signature along with parsed compression info. RPC method guide with use cases, tips and examples.
POST
/
getTransactionWithCompressionInfo
cURL
curl --request POST \
--url 'https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo' \
--header 'Content-Type: application/json' \
--data '
{
"id": "test-account",
"jsonrpc": "2.0",
"method": "getTransactionWithCompressionInfo",
"params": {
"signature": "5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c"
}
}
'import requests
url = "https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo"
payload = {
"id": "test-account",
"jsonrpc": "2.0",
"method": "getTransactionWithCompressionInfo",
"params": { "signature": "5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c" }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: 'test-account',
jsonrpc: '2.0',
method: 'getTransactionWithCompressionInfo',
params: {signature: '5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c'}
})
};
fetch('https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 'test-account',
'jsonrpc' => '2.0',
'method' => 'getTransactionWithCompressionInfo',
'params' => [
'signature' => '5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo"
payload := strings.NewReader("{\n \"id\": \"test-account\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"getTransactionWithCompressionInfo\",\n \"params\": {\n \"signature\": \"5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"test-account\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"getTransactionWithCompressionInfo\",\n \"params\": {\n \"signature\": \"5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://devnet.helius-rpc.com/getTransactionWithCompressionInfo?api-key=%3Capi_key%3E/getTransactionWithCompressionInfo")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"test-account\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"getTransactionWithCompressionInfo\",\n \"params\": {\n \"signature\": \"5J8H5sTvEhnGcB4R8K1n7mfoiWUD9RzPVGES7e3WxC7c\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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": {}
}
}{
"error": {
"code": 123,
"message": "<string>"
},
"id": "<string>",
"jsonrpc": "<string>"
}{
"error": {
"code": 123,
"message": "<string>"
},
"id": "<string>",
"jsonrpc": "<string>"
}The
Common Use Cases
Examples
The below examples work - just make sure you installed the dependencies.
Example: Analyze Transaction
Example: Track Token Balance Changes
getTransactionWithCompressionInfo 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.
- 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
signature(string, required): Base58-encoded transaction signature to query compression information for.
compressionInfo(object): Contains details about compressed account changesclosedAccounts(array): Compressed accounts consumed (spent) in this transactionaccount(object): Complete compressed account data with merkle contextmaybeTokenData(object | null): Token data if this is a compressed token account
openedAccounts(array): New compressed accounts created in this transactionaccount(object): Complete compressed account data with merkle contextmaybeTokenData(object | null): Token data if this is a compressed token account
preTokenBalances(array, optional): Token balances before transactionowner(PublicKey): Public key of token account ownermint(PublicKey): Public key of token mintamount(BN): Token amount as BN object
postTokenBalances(array, optional): Token balances after transactionowner(PublicKey): Public key of token account ownermint(PublicKey): Public key of token mintamount(BN): Token amount as BN object
transaction(object): Standard Solana transaction data
- 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
Transaction not found
Transaction not found
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');
}
No compression info
No compression info
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');
}
Empty account arrays
Empty account arrays
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');
}
Dependencies & Setup
Dependencies & Setup
npm install @lightprotocol/stateless.js
- TypeScript
- cURL
- Rust
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();
curl -X POST https://devnet.helius-rpc.com?api-key=YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTransactionWithCompressionInfo",
"params": {
"signature": "TRANSACTION_SIGNATURE_HERE"
}
}'
Rust Client:
light-client v0.14.0 is available on crates.io. Use LightClient for the current stable API.// Current API: light-client 0.14.0
use light_client::rpc::LightClient;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
let client = LightClient::new("https://devnet.helius-rpc.com/?api-key=YOUR_API_KEY".to_string()).await?;
// Analyze compression transaction
let signature = "TRANSACTION_SIGNATURE_HERE";
match client.get_transaction_with_compression_info(signature).await? {
Some(result) => {
let compression_info = &result.compression_info;
println!("Compression Analysis:");
println!(" Accounts opened: {}", compression_info.opened_accounts.len());
println!(" Accounts closed: {}", compression_info.closed_accounts.len());
// Show account details
for (i, entry) in compression_info.opened_accounts.iter().enumerate() {
println!(" Opened Account {}:", i + 1);
println!(" Hash: {}", entry.account.hash);
println!(" Lamports: {}", entry.account.lamports);
}
}
None => {
println!("Transaction not found or has no compression info");
}
}
Ok(())
}
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
An ID to identify the request.
Available options:
test-account The version of the JSON-RPC protocol.
Available options:
2.0 The name of the method to invoke.
Available options:
getTransactionWithCompressionInfo Show child attributes
Show child attributes
Response
An ID to identify the response.
Available options:
test-account The version of the JSON-RPC protocol.
Available options:
2.0 Show child attributes
Show child attributes
A Solana transaction with additional compression information
Show child attributes
Show child attributes