SwappingIntermediate

Transaction Simulation: Preview a Swap Before You Sign

How simulating the exact transaction catches reverts, wrong balances and malicious contracts before you pay gas, and what a failed simulation tells you.

ChainBridge ResearchUpdated 4 min read

On this page4 sections

Key takeaways

  • Simulation runs your exact transaction against a copy of the current chain state, without broadcasting it, so you see whether it succeeds and what it moves.
  • A reverted transaction still costs gas; simulating first turns that loss into a warning.
  • On ChainBridge, the review screen simulates on-chain routes with Tenderly, including pending approvals, and blocks the swap if it would revert.
  • Simulation reflects the state at that moment: it cannot predict price moves or MEV between review and inclusion.

Why simulate a transaction

On-chain transactions cannot be undone, and a failed one is not free: you pay for the gas used up to the point it reverts. On mainnet that can be several dollars for nothing.

A simulation is a dry run. It takes the same sender, contract, calldata and value as the real transaction and executes them on a temporary copy of the chain. Nothing is broadcast, nothing is spent, and you learn whether the transaction would succeed and which balances it would change. The usual causes of failure it catches:

Price moved past your minimum

The pool changed between quote and execution and the swap can no longer deliver the minimum amount out.

Missing approval or balance

The spender is not approved for enough tokens, or a pending transaction already spent part of your balance.

Token rules

Transfer taxes, maximum transaction sizes, blacklists or paused contracts make the transfer fail.

Stale route

A quote kept open too long can hit an expired deadline or a pool state that no longer matches.

Simulation is also a security check. A malicious contract can look harmless in a quote; executed for real, it would show tokens leaving your wallet that you did not expect.

How simulation works

ChainBridge uses Tenderly, an infrastructure provider that runs transactions on a fork of the live chain at the latest block. The EVM executes every call, transfer and storage write exactly as it would on-chain, then throws the result away.

The request goes from ChainBridge's server to Tenderly, so no key is exposed in your browser. Approvals you have not sent yet are included as calls that run before the swap in the same simulation, so a swap that only works after its approval is judged correctly.

The result says whether the transaction succeeded, how much gas it used and which assets moved. If it reverted, it includes the error message when the contract provides one.

Simulation on ChainBridge

  1. Pick a quote and open the review

    The router has already ranked quotes by net amount. Opening the review rebuilds the winning route as the exact transaction you would send.

  2. Contracts and token are checked

    The contract called and every approval spender are checked against an allowlist, and the token is screened for honeypots and high sell taxes. A failure here blocks the swap outright.

  3. The transaction is simulated

    On-chain routes are sent to the simulator with any pending approvals. This happens automatically; there is no extra button.

  4. Read the result

    A pass lists your expected balance changes. A failure disables the swap and shows the reason. Refresh the quote, try a smaller amount or another route.

What the review screen can show
ResultWhat it means
Simulation passedThe exact transaction succeeds at current state. Your expected balance changes are listed.
Simulation failedIt would revert. The swap button is disabled and the revert reason is shown when available.
Not simulatedGasless orders and Permit2 routes: there is no complete transaction to run before you sign.
Simulation unavailableThe simulator could not answer (network not supported, timeout). You can still decide to proceed.

What simulation cannot tell you

  • The future. State keeps changing after the simulation. A pass means the transaction works now; your minimum amount out is what protects you if the price moves before it lands.
  • MEV. The simulation runs your transaction alone. It cannot show a sandwich attack that happens around it in the mempool. See MEV protection.
  • Exact gas cost. Gas units are measured, but the price per unit is set when the transaction is included.
  • Everything about a token. A token can pass a simulated buy and still carry risks such as an owner able to change taxes later. That is what token safety checks are for.

Treat simulation as a seatbelt: it catches the common failures cheaply, and it works best together with the other checks.

Put it into practice

Compare 0x, KyberSwap and ParaSwap in one quote, with every route checked before you sign.

Start swapping