Prerequisites: You need a Risk API key
and familiarity with the Transaction
Simulator endpoint. You
should also know how to construct Solana transactions using
@solana/kit or
equivalent.When to Simulate
| Scenario | Why Simulate |
|---|---|
| Pre-broadcast validation | Confirm the transaction will succeed before committing it to the blockchain |
| Cost estimation | Get accurate compute units and fee breakdown before signing |
| Debugging | Identify program errors, insufficient balances, or invalid instructions |
| Risk assessment | Check if any accounts involved in the transaction are malicious or suspicious |
| User confirmation | Show users exactly what will happen (balance changes, transfers) before they approve |
Step 1: Prepare and Encode the Transaction
Build your Solana transaction using any SDK and encode it as base64 or base58.Step 2: Submit for Simulation
Single Transaction
Batch Simulation
Use batch simulation when you have multiple transactions to validate - either independent transactions or a sequence of dependent operations.When to Use Each
| Scenario | Use |
|---|---|
| Single transfer or swap | Single simulation |
| Multi-step workflow (approve → swap → transfer) | Batch simulation |
| Validating multiple independent transactions | Batch simulation |
| Portfolio rebalancing across multiple tokens | Batch simulation |
Step 3: Analyze the Response
The simulation response contains several sections. Here’s what to check and in what order:Check for Errors First
If theerror field is present, the transaction would fail onchain. Other
fields may be incomplete.
Review Asset Transfers
Theasset_transfers array shows all token and SOL movements per account. Each
entry represents a balance change for a specific account and asset.
Debit from the sender and
a Credit to the recipient. For swaps or complex transactions, you’ll see
multiple entries across different mints and accounts.
Check Balance Changes
Thelamport_changes array shows the net SOL balance change for each address
involved in the transaction.
Review State Changes
Theexpected_state_changes object maps each affected account to an array of
state changes. Each change includes a humanReadableDiff for display, a
suggestedColor (CREDIT or DEBIT), and rawInfo with structured data about
the change type.
SOL_TRANSFER— Native SOL transfersSPL_TRANSFER— Token transfers, swaps, mints, burns- Account creations, closures, and other token operations
Check Transaction Costs
Fee Confidence Levels
| Level | Meaning | Action |
|---|---|---|
| High | Derived from explicit compute budget instructions | Fee is accurate |
| Medium | Estimated from recent prioritization fees for the locked accounts | Fee is a reasonable estimate |
| Low | No data available; fallback logic used | Consider setting explicit compute budget |
Step 4: Check Transaction Risk
Thetransaction_risk section provides risk analysis for all accounts involved
in the transaction.
riskScore(1-10) andriskLevel(e.g., “Extremely high risk”)numHops— Distance to nearest malicious addressreasoning— Explanation of why the address is flaggedmaliciousAddressesFound— List of connected malicious addresses with their categories (Hack, Scam, etc.)
Risk analysis is performed on the main transaction level. Embedded
transactions (e.g., Squads multisig operations) and nested instruction data
are not currently included in risk scoring.
Debugging Common Failures
| Error Pattern | Likely Cause | Fix |
|---|---|---|
| Insufficient funds | Account doesn’t have enough SOL/tokens | Check balances before building the transaction |
| Account not found | Destination token account doesn’t exist | Create the associated token account first |
| Program error | Invalid instruction data or state | Check program-specific requirements |
| Blockhash expired | Transaction took too long to simulate | Use a fresh recentBlockhash |
| Compute budget exceeded | Transaction is too complex | Add a compute budget instruction with higher limits |
Using Logs for Debugging
Thetransaction_logs array contains the complete execution logs from the
Solana runtime. Search for "Program log: Error" or "failed" to pinpoint the
failing instruction:

