getTransaction

Learn getTransaction use cases, code examples, request parameters, response structure, and tips.

The getTransaction RPC method in CoinVera allows you to retrieve detailed information about a confirmed transaction using its signature. This includes metadata such as slot, block time, fees, execution status, balance changes, logs, and the full transaction structure.


✅ Common Use Cases

  • Transaction Verification Confirm that a transaction was processed and check if it succeeded or failed.

  • Transaction History Display Show detailed transaction info in wallets or explorers.

  • Auditing and Analysis Analyze executed instructions, accounts touched, and fees paid.

  • Debugging Failed Transactions Inspect logMessages and err fields to identify why a transaction failed.

  • Data Indexing Extract structured transaction data for off-chain storage and querying.


🧾 Request Parameters

[
  transactionSignature: string,  // Required – base-58 transaction signature
  options?: {
    commitment?: string,          // Optional – "finalized", "confirmed", etc.
    encoding?: string,            // Optional – Recommended: "jsonParsed"
    maxSupportedTransactionVersion?: number // Optional – Set to 0 to support legacy + versioned
  }
]
  • transactionSignature: Required. The base-58 encoded transaction ID.

  • commitment: Optional. Affects finality level (finalized recommended for accuracy).

  • encoding: Optional. Use "jsonParsed" for human-readable output; "json", "base58", and "base64" are also supported.

  • maxSupportedTransactionVersion: Optional but strongly recommended. Set to 0 to support both legacy and versioned transactions.


📦 Response Structure

Returns null if the transaction is not found or hasn’t reached the specified commitment. Otherwise, it returns an object with:

  • slot: Slot number where the transaction was confirmed.

  • blockTime: Estimated UNIX timestamp (nullable).

  • meta: Metadata about execution:

    • err: Error info if the transaction failed, or null on success.

    • fee: Lamports paid.

    • preBalances / postBalances: Lamport balances of involved accounts.

    • preTokenBalances / postTokenBalances: SPL token balances (if any).

    • innerInstructions: CPI calls and their instructions.

    • logMessages: Logs emitted during execution.

    • loadedAddresses: Accounts loaded via address lookup tables (for versioned txns).

    • returnData: Output returned by the transaction, if applicable.

    • computeUnitsConsumed: Compute units used (if available).

  • transaction:

    • If jsonParsed or json: Includes message, signatures, etc.

    • If base58 or base64: Raw encoded transaction.

  • version: "legacy" or a number (e.g., 0 for versioned txns); undefined if not requested properly.


🧪 Example

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTransaction",
  "params": [
    "5ZQsfqZxPv2h9YurUR9HkEG4grLZAhUNSJmeXrcTRAcKXvLvfbR2fBr3TQadAyQeP5GjZAZ4BLMTrDskmWRGuXMS",
    {
      "encoding": "jsonParsed",
      "commitment": "finalized",
      "maxSupportedTransactionVersion": 0
    }
  ]
}

Code Examples

const fetch = require('node-fetch');

async function getTransaction(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getTransaction',
        "params": [
            "3ec22yxtoMsSZKgEG7yGmLpVqkwQL4mqo4uBJbXJbx3VHAot6zhxLoH9K34hpD5SaeTGc3x4ufFMuA2r8mDJ84eP",
            {
              "encoding": "jsonParsed",
              "maxSupportedTransactionVersion": 0
            }
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getTransaction(RPC_URL);

Example Response

{
  "jsonrpc": "2.0",
  "result": {
    "blockTime": 1753337729,
    "meta": {
      "computeUnitsConsumed": 60796,
      "err": null,
      "fee": 5000,
      "innerInstructions": [
        {
          "index": 0,
          "instructions": [
            {
              "parsed": {
                "info": {
                  "extensionTypes": [
                    "immutableOwner"
                  ],
                  "mint": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v"
                },
                "type": "getAccountDataSize"
              },
              "program": "spl-token",
              "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
              "stackHeight": 2
            },
            {
              "parsed": {
                "info": {
                  "lamports": 2039280,
                  "newAccount": "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G",
                  "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
                  "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx",
                  "space": 165
                },
                "type": "createAccount"
              },
              "program": "system",
              "programId": "11111111111111111111111111111111",
              "stackHeight": 2
            },
            {
              "parsed": {
                "info": {
                  "account": "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G"
                },
                "type": "initializeImmutableOwner"
              },
              "program": "spl-token",
              "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
              "stackHeight": 2
            },
            {
              "parsed": {
                "info": {
                  "account": "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G",
                  "mint": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
                  "owner": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
                },
                "type": "initializeAccount3"
              },
              "program": "spl-token",
              "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
              "stackHeight": 2
            }
          ]
        },
        {
          "index": 1,
          "instructions": [
            {
              "parsed": {
                "info": {
                  "amount": "36680639863",
                  "authority": "791Ln3Yp48TMaLLVLPtVq37BmHKs6VRd49f3pr5fXDui",
                  "destination": "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G",
                  "source": "Bq5y1StGDmqMEpdHkQnD5FTTKzJx2iFxntHseWsm4XQR"
                },
                "type": "transfer"
              },
              "program": "spl-token",
              "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
              "stackHeight": 2
            },
            {
              "parsed": {
                "info": {
                  "destination": "bo5XZZDESRJ9d4qRpFtkuhnLwmaPCCAKRxU7Vy7Wa2E",
                  "lamports": 1008,
                  "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
                },
                "type": "transfer"
              },
              "program": "system",
              "programId": "11111111111111111111111111111111",
              "stackHeight": 2
            },
            {
              "parsed": {
                "info": {
                  "destination": "791Ln3Yp48TMaLLVLPtVq37BmHKs6VRd49f3pr5fXDui",
                  "lamports": 2015097,
                  "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
                },
                "type": "transfer"
              },
              "program": "system",
              "programId": "11111111111111111111111111111111",
              "stackHeight": 2
            },
            {
              "parsed": {
                "info": {
                  "destination": "CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM",
                  "lamports": 19144,
                  "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
                },
                "type": "transfer"
              },
              "program": "system",
              "programId": "11111111111111111111111111111111",
              "stackHeight": 2
            },
            {
              "accounts": [
                "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"
              ],
              "data": "2zjR1PvPvgqdhPdZLxuWCL7t5hN1BQERy9ZVqfANVwkEugCDgFwkVZ7cC3rNSqgFjGu3o3LKtt65Djz2Jmz4EPaSB6aV7pPvFZUsQCvXfahbzon2PAzuWEwugRz2v9aQo8YM449qLHH4q1PioCdDCELW5DMxeS4nXWTeTSLFffcfc4HYz9wnLxohJYu5KFZiJSaK1piDvKKwCUL5skkRNwtPeoxEvvQpq5p22gho759vZ5zn8A3xCrDu6HU7pnbX8rp1YbzGXcospKR48i4hb3GXcS7CniXtkXUksYtUdu3VRNDUaHJ3q87Hd218ecf",
              "programId": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
              "stackHeight": 2
            }
          ]
        }
      ],
      "logMessages": [
        "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]",
        "Program log: CreateIdempotent",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
        "Program log: Instruction: GetAccountDataSize",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1569 of 399097 compute units",
        "Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
        "Program 11111111111111111111111111111111 invoke [2]",
        "Program 11111111111111111111111111111111 success",
        "Program log: Initialize the associated token account",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
        "Program log: Instruction: InitializeImmutableOwner",
        "Program log: Please upgrade to SPL Token 2022 for immutable owner support",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 392511 compute units",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
        "Program log: Instruction: InitializeAccount3",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4188 of 388630 compute units",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
        "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 21841 of 406000 compute units",
        "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success",
        "Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P invoke [1]",
        "Program log: Instruction: Buy",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
        "Program log: Instruction: Transfer",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 364503 compute units",
        "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
        "Program 11111111111111111111111111111111 invoke [2]",
        "Program 11111111111111111111111111111111 success",
        "Program 11111111111111111111111111111111 invoke [2]",
        "Program 11111111111111111111111111111111 success",
        "Program 11111111111111111111111111111111 invoke [2]",
        "Program 11111111111111111111111111111111 success",
        "Program data: vdt/007mYe5rABX35G2eArLr2jFX83hsUZaK2H05GChD2o6TLd/fyXm/HgAAAAAAdyVWiggAAAABixvJSd/FYxLOp+t4sccgNpaW1EonqKlFHM6tZXe6kCeBz4FoAAAAAMolSacJAAAAMtLAk2CuAgDKeSWrAgAAADJi/Qu/7QEArRHmpPwpRKT6glG++BVCbhv7KMa2ZGZ3YHxq2fVmpkZfAAAAAAAAAMhKAAAAAAAAWo6aHeIn3JO5nGpE7od1jBMPEPjqekCW+X5LO0nZq6YFAAAAAAAAAPADAAAAAAAA",
        "Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P invoke [2]",
        "Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P consumed 2009 of 348349 compute units",
        "Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P success",
        "Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P consumed 38655 of 384159 compute units",
        "Program 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P success",
        "Program 11111111111111111111111111111111 invoke [1]",
        "Program 11111111111111111111111111111111 success",
        "Program 11111111111111111111111111111111 invoke [1]",
        "Program 11111111111111111111111111111111 success"
      ],
      "postBalances": [
        6302360,
        2039280,
        4522329612,
        54208476714230,
        11463229419,
        2039280,
        143934559,
        196366793,
        1525925,
        736050881,
        1461600,
        1,
        374025595,
        380770805,
        147104475
      ],
      "postTokenBalances": [
        {
          "accountIndex": 1,
          "mint": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
          "owner": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx",
          "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "uiTokenAmount": {
            "amount": "36680639863",
            "decimals": 6,
            "uiAmount": 36680.639863,
            "uiAmountString": "36680.639863"
          }
        },
        {
          "accountIndex": 5,
          "mint": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
          "owner": "791Ln3Yp48TMaLLVLPtVq37BmHKs6VRd49f3pr5fXDui",
          "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "uiTokenAmount": {
            "amount": "711679772402226",
            "decimals": 6,
            "uiAmount": 711679772.402226,
            "uiAmountString": "711679772.402226"
          }
        }
      ],
      "preBalances": [
        10887933,
        0,
        4522329612,
        54208476695086,
        11461214322,
        2039280,
        143933551,
        196360749,
        1025925,
        736050881,
        1461600,
        1,
        374025595,
        380770805,
        147104475
      ],
      "preTokenBalances": [
        {
          "accountIndex": 5,
          "mint": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
          "owner": "791Ln3Yp48TMaLLVLPtVq37BmHKs6VRd49f3pr5fXDui",
          "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "uiTokenAmount": {
            "amount": "711716453042089",
            "decimals": 6,
            "uiAmount": 711716453.042089,
            "uiAmountString": "711716453.042089"
          }
        }
      ],
      "rewards": [],
      "status": {
        "Ok": null
      }
    },
    "slot": 355371148,
    "transaction": {
      "message": {
        "accountKeys": [
          {
            "pubkey": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx",
            "signer": true,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "791Ln3Yp48TMaLLVLPtVq37BmHKs6VRd49f3pr5fXDui",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "Bq5y1StGDmqMEpdHkQnD5FTTKzJx2iFxntHseWsm4XQR",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "bo5XZZDESRJ9d4qRpFtkuhnLwmaPCCAKRxU7Vy7Wa2E",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "4UJuvGZ7Ge8H3je63Nsb9ZRNVBAd3CG2ajibnRaVSbw5",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe",
            "signer": false,
            "source": "transaction",
            "writable": true
          },
          {
            "pubkey": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "11111111111111111111111111111111",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf",
            "signer": false,
            "source": "transaction",
            "writable": false
          },
          {
            "pubkey": "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1",
            "signer": false,
            "source": "transaction",
            "writable": false
          }
        ],
        "addressTableLookups": [],
        "instructions": [
          {
            "parsed": {
              "info": {
                "account": "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G",
                "mint": "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
                "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx",
                "systemProgram": "11111111111111111111111111111111",
                "tokenProgram": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
                "wallet": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
              },
              "type": "createIdempotent"
            },
            "program": "spl-associated-token-account",
            "programId": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
            "stackHeight": null
          },
          {
            "accounts": [
              "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf",
              "CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM",
              "8CghaJVr4fGoA4A8ag2uosDKKxwV1sGbtx8yFY9rvs3v",
              "791Ln3Yp48TMaLLVLPtVq37BmHKs6VRd49f3pr5fXDui",
              "Bq5y1StGDmqMEpdHkQnD5FTTKzJx2iFxntHseWsm4XQR",
              "iupJ2Lnr2ivuMp3uEFVjrVpPipBoaAT5X7fXny1Fd1G",
              "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx",
              "11111111111111111111111111111111",
              "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
              "bo5XZZDESRJ9d4qRpFtkuhnLwmaPCCAKRxU7Vy7Wa2E",
              "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1",
              "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
            ],
            "data": "AJTQ2h9DXrBsrVNrKZuHZGyjtstmparyM",
            "programId": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
            "stackHeight": null
          },
          {
            "parsed": {
              "info": {
                "destination": "4UJuvGZ7Ge8H3je63Nsb9ZRNVBAd3CG2ajibnRaVSbw5",
                "lamports": 6044,
                "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
              },
              "type": "transfer"
            },
            "program": "system",
            "programId": "11111111111111111111111111111111",
            "stackHeight": null
          },
          {
            "parsed": {
              "info": {
                "destination": "HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe",
                "lamports": 500000,
                "source": "AN2FAtXX4AyZE3mF6uYaVHpuznzgBdKrZCShftkHoUsx"
              },
              "type": "transfer"
            },
            "program": "system",
            "programId": "11111111111111111111111111111111",
            "stackHeight": null
          }
        ],
        "recentBlockhash": "AB3hE6oQuHFsNWbVSM75MxMTMcDwqF3cwBDr4DiQNAf"
      },
      "signatures": [
        "3ec22yxtoMsSZKgEG7yGmLpVqkwQL4mqo4uBJbXJbx3VHAot6zhxLoH9K34hpD5SaeTGc3x4ufFMuA2r8mDJ84eP"
      ]
    },
    "version": 0
  },
  "id": 1
}

💡 Developer Tips

  • Always Set maxSupportedTransactionVersion: 0 To handle both legacy and versioned transactions reliably.

  • Use jsonParsed When Possible Easier to inspect instructions, accounts, and tokens—especially for wallet or dApp UIs.

  • Expect Large Payloads Complex transactions with many instructions/logs can return very large JSON objects.

  • Check for null Values The method will return null for:

    • Incorrect or unknown signatures

    • Unconfirmed transactions (depending on commitment)

    • Incompatible transaction versions (if not configured)

  • Parsing Limitations If a custom program is not recognized, jsonParsed may fallback to base64 format for that instruction.

  • Provider Differences While the RPC spec is consistent, CoinVera may offer enhanced transaction decoding or additional metadata compared to other providers.


The getTransaction method is critical for building detailed transaction explorers, debugging tools, and analytics platforms on Solana. By using jsonParsed and maxSupportedTransactionVersion: 0, you can ensure broad compatibility and full visibility into on-chain activity through CoinVera.

Last updated