GetTransaction

Returns the complete transaction data for a given transaction signature, including the message, signatures, execution metadata, logs, and balance changes. This is the gRPC equivalent of the JSON-RPC getTransaction method.

Use this method to look up specific transactions by their signature, verify execution results, and retrieve detailed metadata such as compute units consumed, inner instructions, and pre/post token balances. This is essential for transaction confirmation flows, debugging, and building transaction explorers.

Type: Unary (request/response)

Parameters

ParameterTypeRequiredDescription
signaturestringYesThe transaction signature as a base-58 encoded string
commitmentCommitmentLevelNoCommitment level: Processed (0), Confirmed (1), or Finalized (2). Default: Finalized

Response

FieldTypeDescription
transactionTransactionThe full transaction object with signatures, message, and account keys
metaTransactionStatusMetaExecution metadata: fee, pre/post balances, inner instructions, logs, compute units
slotuint64The slot the transaction was processed in
block_timeint64Estimated Unix timestamp when the block was produced

Code Examples

Node.js

1const grpc = require('@grpc/grpc-js');
2const protoLoader = require('@grpc/proto-loader');
3
4const packageDef = protoLoader.loadSync('geyser.proto', {
5  keepCase: true, longs: String, enums: String, defaults: true, oneofs: true
6});
7const proto = grpc.loadPackageDefinition(packageDef).geyser;
8const client = new proto.Geyser('[IP_ADDRESS]:[PORT]', grpc.credentials.createInsecure());
9
10const txSignature = '5UfDuX7WXYZbLBfLXwKjMrqPfvTMczAFPbk5oNBhx9TX3GFzM2kXZHvFgnNxPDmS4NLUyN9wQELjS9skByBJiKR';
11
12client.getTransaction({ signature: txSignature, commitment: 2 }, (err, response) => {
13  if (err) { console.error('gRPC error:', err); return; }
14  console.log('Slot:', response.slot);
15  console.log('Block time:', new Date(response.block_time * 1000).toISOString());
16  console.log('Fee:', response.meta.fee, 'lamports');
17  console.log('Compute units:', response.meta.compute_units_consumed);
18  console.log('Success:', response.meta.err === null);
19});

Rust

1use yellowstone_grpc_client::GeyserGrpcClient;
2use yellowstone_grpc_proto::prelude::*;
3
4#[tokio::main]
5async fn main() -> anyhow::Result<()> {
6    let mut client = GeyserGrpcClient::build_from_uri("http://[IP_ADDRESS]:[PORT]")
7        .connect()
8        .await?;
9
10    let signature = "5UfDuX7WXYZbLBfLXwKjMrqPfvTMczAFPbk5oNBhx9TX3GFzM2kXZHvFgnNxPDmS4NLUyN9wQELjS9skByBJiKR";
11    let response = client
12        .get_transaction(signature.to_string(), Some(CommitmentLevel::Finalized as i32))
13        .await?;
14    let tx = response.into_inner();
15
16    println!("Slot: {}", tx.slot);
17    if let Some(meta) = &tx.meta {
18        println!("Fee: {} lamports", meta.fee);
19        println!("Compute units: {}", meta.compute_units_consumed);
20    }
21
22    Ok(())
23}

Example Response

1{
2  "transaction": {
3    "signatures": ["5UfDuX7...BJIKR"],
4    "message": {
5      "account_keys": ["9WzDXwBb..."],
6      "instructions": [{ "program_id_index": 2, "accounts": [0, 1], "data": "..." }]
7    }
8  },
9  "meta": {
10    "err": null,
11    "fee": "5000",
12    "pre_balances": ["1000000000", "500000000"],
13    "post_balances": ["999995000", "500005000"],
14    "compute_units_consumed": "150000",
15    "log_messages": [
16      "Program 11111111111111111111111111111111 invoke [1]",
17      "Program 11111111111111111111111111111111 success"
18    ]
19  },
20  "slot": "250000042",
21  "block_time": "1704067200"
22}