gettransaction

Solana RPC

Archive Method

Only on the full archive nodes. Complex queries might take longer and incur additional cost

How to Use It

// yarn add @tatumio/tatum

import { TatumSDK, Solana, Network } from '@tatumio/tatum'

const tatum = (await TatumSDK.init) < Solana > { network: Network.SOLANA }

const signature = '4CgnQtRfnUekfn21meTyHYvoAc6pBYK3DhimeiZL6a6o2QXMTHqDomninDkaZLmSfdiEzZfyfLGN4mrDvs8HmnBh' // transaction signature

const res = await tatum.rpc.getTransaction(signature)

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The getTransaction method retrieves the details of a specific transaction, identified by its signature. This method can be used to fetch transaction details such as the addresses involved, the amount transacted, the block in which the transaction was included, and so forth.

Parameters

  • signature(string): Transaction signature, as base-58 encoded string
    • Example: "4CgnQtRfnUekfn21meTyHYvoAc6pBYK3DhimeiZL6a6o2QXMTHqDomninDkaZLmSfdiEzZfyfLGN4mrDvs8HmnBh"
  • options (object, optional): Configuration object containing the following fields:
    • commitment (string, optional): Specifies the confirmation level of data to be fetched.
      • Values: finalized confirmed processed
    • maxSupportedTransactionVersion (number): Set the max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned. If this parameter is omitted, only legacy transactions will be returned, and any versioned transaction will prompt the error.
      • Example: 1
    • encoding (string, optional): The encoding for the account data.
      • Values: base58 base64 jsonParsed

Return Object

  • null If transaction is not found or not confirmed
  • object If transaction is confirmed, an object with the following fields:
    • slot: The slot this transaction was processed in
    • transaction: Transaction object, either in JSON format or encoded binary data, depending on encoding parameter
    • blockTime: Estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available
    • meta: Transaction status metadata object:
      • err: Error if transaction failed, null if transaction succeeded.
      • fee: Fee this transaction was charged, as u64 integer
      • preBalances: Array of u64 account balances from before the transaction was processed
      • postBalances: Array of u64 account balances after the transaction was processed
      • innerInstructions: List of inner instructions or null if inner instruction recording was not enabled during this transaction
      • preTokenBalances: List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
      • postTokenBalances: List of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction
      • logMessages: Array of string log messages or null if log message recording was not enabled during this transaction
      • DEPRECATED: status: Transaction status
        • "Ok": Transaction was successful
        • "Err": Transaction failed with TransactionError
      • rewards: Transaction-level rewards, populated if rewards are requested; an array of JSON objects containing:
        • pubkey: The public key, as base-58 encoded string, of the account that received the reward
        • lamports:Number of reward lamports credited or debited by the account, as a i64
        • postBalance: Account balance in lamports after the reward was applied
        • rewardType: Type of reward: currently only "rent", other types may be added in the future
        • commission: Vote account commission when the reward was credited, only present for voting and staking rewards
      • loadedAddresses: Transaction addresses loaded from address lookup tables. Undefined if maxSupportedTransactionVersion is not set in request params.
        • writable: Ordered list of base-58 encoded addresses for writable loaded accounts
        • readonly: Ordered list of base-58 encoded addresses for readonly loaded accounts
      • returnData: The most-recent return data generated by an instruction in the transaction, with the following fields:
        • programId: The program that generated the return data, as base-58 encoded Pubkey
        • data: The return data itself, as base-64 encoded binary data
      • computeUnitsConsumed: Number of compute units consumed by the transaction
    • version: Transaction version. Undefined if maxSupportedTransactionVersion is not set in request params.

JSON-RPC Request Example

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTransaction",
  "params": [
    "4CgnQtRfnUekfn21meTyHYvoAc6pBYK3DhimeiZL6a6o2QXMTHqDomninDkaZLmSfdiEzZfyfLGN4mrDvs8HmnBh",
    {
      "encoding": "jsonParsed"
    }
  ]
}

JSON-RPC Response Example

{
  "jsonrpc": "2.0",
  "result": {
    "meta": {
      "err": null,
      "fee": 5000,
      "innerInstructions": [],
      "postBalances": [499998932500, 26858640, 1, 1, 1],
      "postTokenBalances": [],
      "preBalances": [499998937500, 26858640, 1, 1, 1],
      "preTokenBalances": [],
      "rewards": [],
      "status": {
        "Ok": null
      }
    },
    "slot": 430,
    "transaction": {
      "message": {
        "accountKeys": [
          "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe",
          "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc",
          "SysvarS1otHashes111111111111111111111111111",
          "SysvarC1ock11111111111111111111111111111111",
          "Vote111111111111111111111111111111111111111"
        ],
        "header": {
          "numReadonlySignedAccounts": 0,
          "numReadonlyUnsignedAccounts": 3,
          "numRequiredSignatures": 1
        },
        "instructions": [
          {
            "accounts": [1, 2, 3, 0],
            "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1",
            "programIdIndex": 4
          }
        ],
        "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"
      },
      "signatures": [
        "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"
      ]
    }
  },
  "blockTime": null,
  "id": 1
}