getTransaction
Returns the complete transaction details for a confirmed transaction given its signature. This is the primary method for retrieving transaction information, supporting both legacy and versioned transactions. It returns the full transaction message, metadata (including pre/post balances, log messages, and inner instructions), slot, and block time. This method is essential for block explorers, transaction debugging, and building detailed transaction history views.
Parameters
| # | Type | Required | Description |
|---|---|---|---|
| 1 | string | Yes | Transaction signature (base-58 encoded) |
| 2 | object | No | Configuration object |
Configuration object fields:
| Field | Type | Description |
|---|---|---|
commitment | string | Commitment level: confirmed or finalized (default finalized) |
encoding | string | Transaction encoding: json, jsonParsed, base58, or base64 (default json) |
maxSupportedTransactionVersion | number | Max transaction version to return. Set to 0 to support versioned transactions |
Response
Returns null if the transaction is not found. Otherwise returns an object:
| Field | Type | Description |
|---|---|---|
slot | u64 | The slot the transaction was processed in |
transaction | object | Transaction object (format depends on encoding) |
blockTime | `i64 | null` |
meta | `object | null` |
meta.fee | u64 | Transaction fee in lamports |
meta.err | `object | null` |
meta.logMessages | `array[string] | null` |
version | `"legacy" | number` |
Code Examples
cURL
1curl http://[IP_ADDRESS]:[PORT] -X POST -H "Content-Type: application/json" -d '{
2 "jsonrpc": "2.0",
3 "id": 1,
4 "method": "getTransaction",
5 "params": [
6 "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
7 {
8 "encoding": "jsonParsed",
9 "commitment": "confirmed",
10 "maxSupportedTransactionVersion": 0
11 }
12 ]
13}'TypeScript
1const response = await fetch("http://[IP_ADDRESS]:[PORT]", {
2 method: "POST",
3 headers: { "Content-Type": "application/json" },
4 body: JSON.stringify({
5 jsonrpc: "2.0",
6 id: 1,
7 method: "getTransaction",
8 params: [
9 "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
10 {
11 encoding: "jsonParsed",
12 commitment: "confirmed",
13 maxSupportedTransactionVersion: 0
14 }
15 ]
16 }),
17});
18const { result } = await response.json();
19console.log("Fee:", result.meta.fee, "lamports, Status:", result.meta.err ? "Failed" : "Success");Python
1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4 "jsonrpc": "2.0",
5 "id": 1,
6 "method": "getTransaction",
7 "params": [
8 "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
9 {
10 "encoding": "jsonParsed",
11 "commitment": "confirmed",
12 "maxSupportedTransactionVersion": 0
13 }
14 ]
15})
16result = response.json()["result"]
17print(f"Fee: {result['meta']['fee']} lamports, Status: {'Failed' if result['meta']['err'] else 'Success'}")Rust
1use reqwest::Client;
2use serde_json::json;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let client = Client::new();
7 let res = client.post("http://[IP_ADDRESS]:[PORT]")
8 .json(&json!({
9 "jsonrpc": "2.0",
10 "id": 1,
11 "method": "getTransaction",
12 "params": [
13 "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
14 {
15 "encoding": "jsonParsed",
16 "commitment": "confirmed",
17 "maxSupportedTransactionVersion": 0
18 }
19 ]
20 }))
21 .send().await?
22 .text().await?;
23 println!("{}", res);
24 Ok(())
25}Example Response
1{
2 "jsonrpc": "2.0",
3 "result": {
4 "slot": 166974442,
5 "transaction": {
6 "message": {
7 "accountKeys": [],
8 "instructions": [],
9 "recentBlockhash": "GJxqhuxcgfn5Tcj6y3f8X4FeCDd2RQ6SnEMo1AAxrPRZ"
10 },
11 "signatures": ["5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW"]
12 },
13 "meta": {
14 "fee": 5000,
15 "err": null,
16 "logMessages": ["Program 11111111111111111111111111111111 invoke [1]", "Program 11111111111111111111111111111111 success"]
17 },
18 "blockTime": 1681391935,
19 "version": "legacy"
20 },
21 "id": 1
22}