getTransaction — Solana RPC Method
getTransaction returns the complete details of a confirmed transaction, including its instructions, account keys, pre/post balances, log messages, and any errors. This is the primary method for inspecting what a specific transaction did.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
signature | string | Yes | Base-58 encoded transaction signature. |
commitment | string | No | confirmed or finalized. processed is not supported. Default: finalized. |
encoding | string | No | json, jsonParsed, base58, base64. Default: json. |
maxSupportedTransactionVersion | number | No | Set to 0 to include versioned transactions. |
Request
curl -X POST https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTransaction",
"params": [
"5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
{"encoding": "jsonParsed", "maxSupportedTransactionVersion": 0}
]
}'
TypeScript (@solana/kit)
import { createSolanaRpc, signature } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const tx = await rpc
.getTransaction(
signature("5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW"),
{ encoding: "jsonParsed", maxSupportedTransactionVersion: 0 }
)
.send();
if (tx) {
console.log(`Slot: ${tx.slot}, Fee: ${tx.meta?.fee}`);
}
Response
{
"jsonrpc": "2.0",
"result": {
"slot": 341199500,
"blockTime": 1729000000,
"meta": {
"err": null,
"fee": 5000,
"preBalances": [100000000, 50000000],
"postBalances": [99995000, 50005000],
"preTokenBalances": [],
"postTokenBalances": [],
"logMessages": [
"Program 11111111111111111111111111111111 invoke [1]",
"Program 11111111111111111111111111111111 success"
],
"computeUnitsConsumed": 150
},
"transaction": {
"message": {
"accountKeys": ["sender-pubkey", "recipient-pubkey"],
"instructions": [{ "...": "..." }],
"recentBlockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N"
},
"signatures": ["5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRn..."]
},
"version": 0
},
"id": 1
}
| Field | Type | Description |
|---|---|---|
slot | u64 | The slot the transaction was included in. |
blockTime | i64 or null | Estimated Unix timestamp of the block. |
meta.err | object or null | null if successful, error object if failed. |
meta.fee | u64 | Transaction fee in lamports. |
meta.preBalances | u64[] | Account balances before the transaction (in order of account keys). |
meta.postBalances | u64[] | Account balances after the transaction. |
meta.logMessages | string[] | Program log messages emitted during execution. |
meta.computeUnitsConsumed | u64 | Compute units consumed by the transaction. |
transaction | object | The transaction data (format depends on encoding). |
version | number or “legacy” | Transaction version. 0 for versioned, "legacy" for legacy. |
Returns null if the transaction is not found.
Common errors
- Transaction not found — returns
null. The transaction may be too old for the node’s history, or the signature is invalid. - Versioned transaction excluded — omitting
maxSupportedTransactionVersionmay cause v0 transactions to fail. Always set it to0. - processed not supported — use
confirmedorfinalized.
Performance
getTransaction fetches a single transaction from the ledger. Response size varies with transaction complexity — simple transfers are small, complex DeFi transactions with many instructions can be large. Use jsonParsed encoding for readable output.
FAQ
Why does getTransaction return null? Either the transaction was not found (invalid signature, not yet confirmed, or too old for the node’s history) or it was never submitted to the network.
How do I read the instructions?
With jsonParsed encoding, known programs (System, Token, Stake, etc.) return structured instruction data. Unknown programs return raw data that you need to decode using the program’s IDL or documentation.
What are log messages?
Programs emit log messages during execution using msg!() or sol_log(). These appear in meta.logMessages and are useful for debugging and understanding what the program did.
How far back can I query transactions? Non-archival nodes typically keep 2-4 days of transaction history. For older transactions, use an archival RPC provider.
What is the version field?
0 indicates a versioned transaction (supports address lookup tables). "legacy" indicates a legacy transaction format. Set maxSupportedTransactionVersion: 0 to receive both types.
Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
signature | string | Yes | Base-58 encoded transaction signature. | — |
commitment | string | No | confirmed or finalized. processed is not supported. | finalized |
encoding | string | No | Transaction encoding: json, jsonParsed, base58, base64. | json |
maxSupportedTransactionVersion | number | No | Maximum transaction version to return. Set to 0 for versioned transactions. | — |
Updated: