Simulate a transaction
Dry-run a transaction and see logs, compute usage, and errors — without paying a fee.
POST /transactions/simulateRuns a transaction against current chain state without submitting it. Use it to preview effects, debug program errors, and measure compute usage while building.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
transaction | string | Yes | The transaction, base64-encoded. Signatures are not required. |
replaceBlockhash | boolean | No | Default true: simulate against a fresh blockhash so stale drafts still work. Set false to also validate your blockhash. |
Example
curl -X POST https://api.sarg.am/v1/solana/transactions/simulate \
-H "Authorization: Bearer $MAINLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "transaction": "AeF3...base64-encoded-transaction...==" }'Success:
{
"success": true,
"computeUnits": 4250,
"logs": [
"Program 11111111111111111111111111111111 invoke [1]",
"Program 11111111111111111111111111111111 success"
],
"error": null
}Failure:
{
"success": false,
"computeUnits": 1802,
"logs": [
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
"Program log: Error: insufficient funds",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0x1"
],
"error": {
"code": "programError",
"message": "Instruction 0 failed: insufficient funds",
"programErrorCode": "0x1"
}
}A failed simulation is still an HTTP 200 — the simulation succeeded; the
transaction it simulated would fail. You only get a 4xx/5xx when the request
itself is malformed.
Response fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the transaction would execute successfully. |
computeUnits | number | Compute units consumed — useful for setting compute budgets. |
logs | array | Full program log output. |
error | object | null | Structured failure info when success is false. |
Errors
code | When |
|---|---|
invalid_transaction | The body isn't a decodable base64 transaction. |
Under the hood
Replaces simulateTransaction with its sigVerify/replaceRecentBlockhash
interplay and encoding requirements.