confirmTransaction

Note: This is a client-side helper method, not a standard Solana JSON-RPC endpoint. It is provided by client libraries such as @solana/web3.js and internally uses getSignatureStatuses to poll for transaction confirmation.

This is a client-side helper method, not a standard Solana JSON-RPC endpoint. It is commonly provided by Solana client libraries (such as @solana/web3.js) to poll for transaction confirmation. Under the hood, it typically calls getSignatureStatuses repeatedly until the transaction reaches the desired commitment level or times out. It simplifies the common pattern of waiting for transaction confirmation after submission.

Parameters

#TypeRequiredDescription
1stringYesTransaction signature (base-58 encoded)
2objectNoConfiguration object

Configuration object fields:

FieldTypeDescription
commitmentstringTarget commitment level: processed, confirmed, or finalized

Response

Returns an RpcResponse containing the signature status:

FieldTypeDescription
context.slotu64The slot at which the status was evaluated
value.err`objectnull`

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": "confirmTransaction",
5  "params": [
6    "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
7    { "commitment": "confirmed" }
8  ]
9}'

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: "confirmTransaction",
8    params: [
9      "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
10      { commitment: "confirmed" }
11    ]
12  }),
13});
14const { result } = await response.json();
15console.log("Transaction confirmed:", result.value.err === null ? "Success" : "Failed");

Python

1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4    "jsonrpc": "2.0",
5    "id": 1,
6    "method": "confirmTransaction",
7    "params": [
8        "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
9        {"commitment": "confirmed"}
10    ]
11})
12result = response.json()["result"]
13print(f"Transaction confirmed: {'Success' if result['value']['err'] is None else 'Failed'}")

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": "confirmTransaction",
12            "params": [
13                "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
14                {"commitment": "confirmed"}
15            ]
16        }))
17        .send().await?
18        .text().await?;
19    println!("{}", res);
20    Ok(())
21}

Example Response

1{
2  "jsonrpc": "2.0",
3  "result": {
4    "context": { "slot": 166974442 },
5    "value": {
6      "err": null
7    }
8  },
9  "id": 1
10}