How to Simulate a Transaction
If you ever used the JSON-RPC, you've probably stumbled upon eth_call. If you haven't, it returns you the output of a Smart Contract function, without submitting an on-chain transaction. This can be useful in some cases, but it is quite limited.
With the Simulate tool, you can provide the data for a transaction and see what would happen if you submitted the transaction right now. So you get all of the tools we already offer for on-chain transactions for the pending block.
Not only that, but you can even pick a specific block height, transaction index and get the output of the transaction as if it happened at that specific point in time.
You can simulate any transaction on Tenderly in several ways. One of the easiest and probably most used ones would be to choose a desired on-chain transaction from the Transactions tab in the left navigation pane:
You can also start the simulation by going to the Simulator tab in the left navigation pane and clicking on New Simulation in the top right, making it possible to run completely custom simulations:
So let's start up a new simulation with a public contract:
The simulated transaction will fail due to insufficient Dai balance:
You can immediately jump into the debugger and get to the line of code that caused the transaction to fail:
The transaction failed again in a different place which was expected since we deleted a part of the code:
Clicking the back arrow or clicking on the Simulator tab in the left navigation pane brings you (back) to the historical list of all simulations: