simulateTransaction
Simulates sending a transaction. This performs all the same checks as sendTransaction (signature verification, balance checks, program execution) without actually submitting the transaction to the cluster. It returns the execution result including logs, compute units consumed, and any errors. This is invaluable for transaction debugging, fee estimation, validating transaction construction, and pre-flight checks before committing real transactions.
Parameters
| # | Type | Required | Description |
|---|---|---|---|
| 1 | string | Yes | Transaction as an encoded string. Must be base-64 encoded |
| 2 | object | No | Configuration object |
Configuration object fields:
| Field | Type | Description |
|---|---|---|
commitment | string | Commitment level: processed, confirmed, or finalized |
encoding | string | Encoding of the transaction: base64 (default base64) |
sigVerify | bool | If true, verify transaction signatures (default false; conflicts with replaceRecentBlockhash) |
replaceRecentBlockhash | bool | If true, replace the transaction's blockhash with the latest (default false) |
accounts | object | Accounts configuration: { addresses: string[], encoding: string } |
minContextSlot | number | Minimum slot at which the request can be evaluated |
innerInstructions | bool | If true, include inner instructions in the response |
Response
Returns an RpcResponse object:
| Field | Type | Description |
|---|---|---|
context.slot | u64 | The slot at which the simulation was evaluated |
value.err | `object | null` |
value.logs | `array[string] | null` |
value.accounts | `array | null` |
value.unitsConsumed | u64 | Number of compute units consumed during simulation |
value.returnData | `object | null` |
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": "simulateTransaction",
5 "params": [
6 "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk2TIQ0/jAgPDtfEP82jE2NpNsAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSbxFRHKFUzK0X+2KniPE+eNjjVy10Ezz0o5/SCCr73AQIAAQA=",
7 {
8 "encoding": "base64",
9 "replaceRecentBlockhash": true
10 }
11 ]
12}'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: "simulateTransaction",
8 params: [
9 "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk2TIQ0/jAgPDtfEP82jE2NpNsAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSbxFRHKFUzK0X+2KniPE+eNjjVy10Ezz0o5/SCCr73AQIAAQA=",
10 {
11 encoding: "base64",
12 replaceRecentBlockhash: true
13 }
14 ]
15 }),
16});
17const { result } = await response.json();
18console.log("Simulation:", result.value.err ? "Failed" : "Success", "CU:", result.value.unitsConsumed);Python
1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4 "jsonrpc": "2.0",
5 "id": 1,
6 "method": "simulateTransaction",
7 "params": [
8 "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk2TIQ0/jAgPDtfEP82jE2NpNsAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSbxFRHKFUzK0X+2KniPE+eNjjVy10Ezz0o5/SCCr73AQIAAQA=",
9 {
10 "encoding": "base64",
11 "replaceRecentBlockhash": True
12 }
13 ]
14})
15result = response.json()["result"]
16print(f"Simulation: {'Failed' if result['value']['err'] else 'Success'}, CU: {result['value']['unitsConsumed']}")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": "simulateTransaction",
12 "params": [
13 "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk2TIQ0/jAgPDtfEP82jE2NpNsAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSbxFRHKFUzK0X+2KniPE+eNjjVy10Ezz0o5/SCCr73AQIAAQA=",
14 {
15 "encoding": "base64",
16 "replaceRecentBlockhash": true
17 }
18 ]
19 }))
20 .send().await?
21 .text().await?;
22 println!("{}", res);
23 Ok(())
24}Example Response
1{
2 "jsonrpc": "2.0",
3 "result": {
4 "context": { "slot": 166974442 },
5 "value": {
6 "err": null,
7 "logs": [
8 "Program 11111111111111111111111111111111 invoke [1]",
9 "Program 11111111111111111111111111111111 success"
10 ],
11 "accounts": null,
12 "unitsConsumed": 150,
13 "returnData": null
14 }
15 },
16 "id": 1
17}