Simulate Before You Swap: Preview Transactions with Tenderly
See exactly what will happen before you sign. Transaction simulation runs your swap against a fork of the live blockchain, showing you the output, gas cost, and potential failures -- without spending a cent.
Key Takeaways
- Transaction simulation executes your swap on a blockchain fork, revealing exact outputs and gas costs before you commit
- Failed simulations save you real money -- you avoid paying gas for transactions that would revert on-chain
- ChainBridge integrates Tenderly simulation directly into the swap flow with a single click
- Simulation is especially valuable for large trades, unfamiliar tokens, and complex multi-hop routes
Table of Contents
- Why Simulate Transactions?
- How Tenderly Simulation Works
- What You See in a Simulation
- When to Use Simulation
- Step-by-Step on ChainBridge
- Limitations
Why Simulate Transactions?
On-chain transactions are irreversible. Once you sign and broadcast a swap, it either succeeds or fails -- and if it fails, you still pay the gas fee. On Ethereum mainnet, a failed swap can cost $10 to $50 in wasted gas. Over time, failed transactions add up to significant losses.
Transaction simulation solves this by letting you execute a dry run against the live blockchain state. The simulation runs your exact transaction -- same calldata, same gas parameters, same token amounts -- on a temporary fork of the chain. You see the full result without broadcasting anything.
Common reasons transactions fail in DeFi:
- Slippage exceeded: Pool prices moved between when you got the quote and when your transaction was mined. The minimum output amount was not met.
- Insufficient approval: You did not approve enough tokens for the spender contract. The transferFrom call reverts.
- Deadline expired: Many swap routers include a deadline parameter. If your transaction is pending in the mempool too long, it expires.
- Insufficient balance: Your token balance changed (perhaps from a pending transaction) and you no longer have enough to cover the swap amount.
- Token-specific issues: Some tokens have transfer taxes, maximum transaction amounts, or pausing mechanisms that cause unexpected reverts.
Simulation catches all of these before you pay gas. It is the difference between flying blind and having full visibility into what your transaction will do.
How Tenderly Simulation Works
Tenderly is an infrastructure provider that offers blockchain simulation as a service. When ChainBridge sends a simulation request, here is what happens behind the scenes:
First, Tenderly creates a fork of the blockchain at the latest block. This fork contains the complete state of every contract, token balance, and approval on the network. It is an exact copy of the live chain at that moment.
Next, your transaction is executed against this fork. The EVM processes every opcode, every internal call, every storage read and write -- exactly as it would on the real chain. The only difference is that the results are never committed to the actual blockchain.
Finally, Tenderly returns a detailed execution trace. This includes the final token balances, gas consumed, any events emitted, and if the transaction reverted, the exact revert reason and the line of code that caused it.
The entire process takes 2-5 seconds. ChainBridge calls the Tenderly API server-side through the /api/simulation endpoint, so your API keys and transaction details stay secure and never leave the backend.
What You See in a Simulation
A ChainBridge simulation result shows you the following information:
The most important field is revert detection. If a simulation shows your transaction would revert, you avoid paying gas for a guaranteed failure. The revert reason tells you exactly what to fix: increase slippage, approve tokens, use a different route, or wait for better market conditions.
When to Use Simulation
While you can simulate every transaction, certain situations benefit the most from pre-execution verification:
Large trades (over $10,000)
Price impact and slippage can be significant on large trades. Simulation shows you the exact output so you can decide if the effective price is acceptable before committing.
Unfamiliar tokens
Some tokens have transfer fees, rebasing mechanics, or other non-standard behavior. Simulation reveals these surprises before you lose money to unexpected token mechanics.
Complex multi-hop routes
When the Smart Order Router splits your trade across multiple DEXes or routes through intermediate tokens, simulation verifies the entire path executes correctly.
High-congestion periods
During volatile markets, pool states change rapidly. A quote that was valid 30 seconds ago may no longer be executable. Simulation checks against the latest state.
First interaction with a new protocol
When swapping through a DEX or liquidity source you have not used before, simulation confirms the contract behaves as expected before you grant approvals.
After failed transactions
If a previous swap reverted (costing you gas), simulate the next attempt to understand and fix the failure before paying gas again.
Step-by-Step on ChainBridge
Simulating a swap on ChainBridge takes one extra click. Here is the complete flow:
Configure Your Swap
Select your sell token, buy token, amount, and slippage on the ChainBridge swap page. The Smart Order Router will find the best quote across all 7 aggregators.
Click "Preview Swap"
Before signing, click the simulation button. ChainBridge sends your transaction parameters to the Tenderly Simulation API, which executes the transaction against a fork of the current blockchain state.
Review Simulation Results
You will see the exact output amount, gas cost estimate, token balance changes, and any approval transactions required. If the transaction would revert, the simulator tells you why.
Check for Warnings
The simulation flags potential issues: high price impact, unusual gas consumption, failed internal calls, or unexpected token transfers. Address any warnings before proceeding.
Execute or Adjust
If the simulation looks clean, proceed to sign and submit. If something is wrong, adjust your parameters (different slippage, smaller amount, different route) and simulate again.
The simulation result appears in a panel below your swap details. Green indicates the transaction would succeed. Red indicates a revert, with the specific error message shown. You can re-simulate at any time after adjusting your parameters.
Limitations
Simulation is a powerful tool but not a guarantee. Be aware of these constraints:
- State can change between simulation and execution: Blockchain state is not frozen. Between the time you simulate and the time your transaction is mined, other transactions may change pool balances, gas prices, or token states. This is especially relevant during high volatility.
- Gas price fluctuation: The gas cost shown in simulation uses the current gas price. If gas prices spike between simulation and submission, your actual cost will be higher. On L2 chains, gas is stable enough that this is rarely an issue.
- Simulation adds a few seconds of latency: Running a full simulation takes 2-5 seconds depending on transaction complexity. For time-sensitive trades (arbitrage, fast-moving markets), this delay may not be acceptable.
- MEV is not simulated: Simulation runs your transaction in isolation. It cannot predict frontrunning or sandwich attacks that may occur when your transaction enters the mempool. Use private mempools or gasless swaps for MEV protection.
- Not available for all transaction types: Simulation works for standard swap and approval transactions. Complex interactions like multi-step DeFi strategies or cross-chain bridge transactions may not be fully simulatable.
Despite these limitations, simulation catches the vast majority of common failures. Think of it as a seatbelt: it does not prevent all accidents, but it dramatically reduces the damage when something goes wrong.
Related Articles
Try a Swap with Simulation
Preview your next trade before signing. See exact outputs, gas costs, and catch failures before they cost you money.