Send an unsigned Solana transaction to simulateTransaction with sigVerify false, then inspect its execution result and post-state token accounts before signing. A rugcheck reviews the token for scam and rug-pull warning signs; simulation adds a check of what this particular swap would do to your balances. If err is null and the destination account’s simulated increase matches your quote within tolerance, you have a basis for signing.
How do you verify a Solana swap’s output before signing?
Verify the swap by comparing the destination token account before and after simulated execution. You need an RPC endpoint, the transaction serialized as base64, and the token account addresses involved.
-
Export the unsigned transaction. Say your token passed rugcheck and your bot has built a swap, but the wallet has not shown a signing prompt yet. Export that transaction’s wire bytes with empty signature slots and encode them as base64. Keep the instructions, account keys, fee payer, and slippage limit that you intend to sign. The result of this step is a transaction you can test without broadcasting it.
-
Record the pre-state. Read your source and destination token accounts with getMultipleAccounts or getAccountInfo. Record each token account’s raw amount, mint, and owner. If the swap creates your destination associated token account, note that it does not exist yet and use zero as its starting token amount. Take these reads immediately before simulation at the same commitment level. You now have the balances against which to measure the simulated result.
-
Run simulateTransaction and request accounts. Send the base64 transaction as the first RPC parameter. Set encoding to base64, sigVerify to false, and replaceRecentBlockhash to true. Signature verification and blockhash replacement cannot both be enabled. In accounts, list your source and destination token accounts and the pool’s relevant token vaults; set the account-data encoding to jsonParsed. The response returns post-execution account data in the order requested. Pool vaults help confirm which reserves the route touched, while your destination account gives the received amount. The Solana RPC reference specifies these parameters and the returned fields.
-
Read the execution result. Inspect result.value.err and result.value.logs together. Stop if err is non-null: an InstructionError identifies the failing instruction, and the logs show the program calls and error path. A null err means execution succeeded against the state at result.context.slot. Read unitsConsumed if you are checking the transaction’s compute budget. Successful logs establish that instructions ran; the requested account data establishes how many tokens this run delivered.
-
Compare the output and decide. For the destination account, read data.parsed.info.tokenAmount.amount as an integer string, or decode the base64 token-account data if parsing fell back to binary. Subtract the recorded pre-state amount in raw token units, then compare that delta with the quoted output and the transaction’s minimum receive. Say the destination is a USDC token account: the pre-state gives its starting balance, the simulated post-state gives its projected balance, and their difference is the swap’s projected USDC output. Sign and send only when that difference meets your tolerance and the source and pool changes make sense.
On an EVM chain, eth_call executes a call without creating a transaction; a Tenderly simulation or Foundry fork offers another dry run. Use the same principle: inspect state changes as well as execution success. The go-ethereum RPC documentation describes eth_call’s transaction-effect check.
Simulation uses the node’s current state, which can change before your swap lands. Keep the minimum receive in the transaction. If its original blockhash has expired, rebuild and simulate again before signing: replaceRecentBlockhash refreshes the simulation’s blockhash, not the transaction bytes you will submit.
Related checks
These checks help explain a failed simulation or a transaction that runs short of compute.
How to read Solana transaction logs?
Read logs in invocation order and pair them with err’s instruction index. Follow nested program calls to the first error, then identify the instruction and account that caused it. After a transaction is submitted, Solscan can display its program logs and instruction details; for an unsigned attempt, use the RPC simulation response.
What is a compute unit limit on Solana?
A compute unit limit caps the computation a transaction can use. Compare the transaction’s limit with unitsConsumed from a successful simulation and leave room for execution variance. A limit below the required work can cause the transaction to fail.
What else should you check before signing?
Use the simulated balance changes to inspect what the transaction actually authorizes.
How do wallets show balance changes before signing?
Wallets that offer previews can simulate the unsigned transaction, identify token accounts affected, and turn account deltas into a readable summary. The preview depends on the wallet’s parsing and the state used for simulation, so inspect the raw destination and source accounts when the amount matters.
Can a wallet drainer pass transaction simulation?
Yes. A transaction that transfers your tokens to an attacker can execute successfully in simulation. Inspect outgoing token amounts, recipient accounts, approvals or delegated authority, and every instruction before signing. Execution success alone is not a safety verdict.