in-solana by Supanode

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

NameTypeRequiredDescription
signaturestringYesBase-58 encoded transaction signature.
commitmentstringNoconfirmed or finalized. processed is not supported. Default: finalized.
encodingstringNojson, jsonParsed, base58, base64. Default: json.
maxSupportedTransactionVersionnumberNoSet 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
}
FieldTypeDescription
slotu64The slot the transaction was included in.
blockTimei64 or nullEstimated Unix timestamp of the block.
meta.errobject or nullnull if successful, error object if failed.
meta.feeu64Transaction fee in lamports.
meta.preBalancesu64[]Account balances before the transaction (in order of account keys).
meta.postBalancesu64[]Account balances after the transaction.
meta.logMessagesstring[]Program log messages emitted during execution.
meta.computeUnitsConsumedu64Compute units consumed by the transaction.
transactionobjectThe transaction data (format depends on encoding).
versionnumber 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 maxSupportedTransactionVersion may cause v0 transactions to fail. Always set it to 0.
  • processed not supported — use confirmed or finalized.

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

ParameterTypeRequiredDescriptionDefault
signaturestringYesBase-58 encoded transaction signature.—
commitmentstringNoconfirmed or finalized. processed is not supported.finalized
encodingstringNoTransaction encoding: json, jsonParsed, base58, base64.json
maxSupportedTransactionVersionnumberNoMaximum transaction version to return. Set to 0 for versioned transactions.—

Updated: