Mainly

Simulate a transaction

Dry-run a transaction and see logs, compute usage, and errors — without paying a fee.

POST /transactions/simulate

Runs 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

FieldTypeRequiredDescription
transactionstringYesThe transaction, base64-encoded. Signatures are not required.
replaceBlockhashbooleanNoDefault 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

FieldTypeDescription
successbooleanWhether the transaction would execute successfully.
computeUnitsnumberCompute units consumed — useful for setting compute budgets.
logsarrayFull program log output.
errorobject | nullStructured failure info when success is false.

Errors

codeWhen
invalid_transactionThe body isn't a decodable base64 transaction.

Under the hood

Replaces simulateTransaction with its sigVerify/replaceRecentBlockhash interplay and encoding requirements.

On this page