FAQ: Simulations
Can I delete a simulation?
No, simulations cannot be deleted. Feel free to contact support via the in-app chat or support@tenderly.co should you have additional questions.
Can I advance a block number/timestamp in a simulation?
Yes, you can advance the block number or timestamp in a simulation. To do this, please follow these steps.
Can I simulate transactions on behalf of a user without their private key? In other words, can I simulate transactions originating from arbitrary addresses?
In simulations, all addresses are unlocked by default. This means you can simulate transactions from any address to any address.
Learn more about how to use Transaction Simulator in development and testing here.
What is the correct format of a tuple when simulating a transaction via the Dashboard?
The format for tuples is JSON. Here’s an example of a tuple:
{
"tokenIn": "0x3Df2f692132f55b97cc9DA04A1fFFEA82F511333",
"tokenOut": "0x31254874432f55b97cc9DA04A1fFFEA82F5d7122",
"fee": 100,
"recipient": "0x3D555552132f55b97cc9DA04A1fFFEA82F5d7122",
"deadline": 1630403200,
"amountIn": 10000,
"amountOutMinimum": 9000,
"sqrtPriceLimitX96": 7894561250
}
An example from Simulator UI:
How can I integrate Tenderly simulations into the UI for previewing transaction outcomes for users?
You can integrate Tenderly’s Simulation API or Simulation RPC into your dApp UI by calling the API to simulate transactions and display the resulting state changes, asset movements, and gas estimates to users before they confirm transactions.
Can I simulate contract interactions that involve multiple external smart contracts?
Yes, bundled simulations allow you to test multiple contract interactions in one simulation. The state is updated after each transaction, allowing you to verify complex contract interactions.
You can also simulate bundles of transaction using tenderly_simulateBundle
RPC
Can I estimate the gas required for contract functions using the simulation API?
Yes, the gas estimation feature in Tenderly allows you to simulate contract functions and get an accurate gas estimate before the transaction is executed. This helps ensure the transaction will succeed and minimizes gas costs.
Besides Simulation API, you can use tenderly_estimateGas
and tenderly_estimateGasBundle
.
How do bundled simulations help in testing complex workflows with multiple contract calls?
Bundled simulations allow you to simulate multiple transactions in sequence, preserving the state from one transaction to the next. This is useful for testing complex workflows, such as multi-contract interactions or dApp user flows.
How do I trigger simulations programmatically from the backend to verify transaction success before execution?
You can trigger simulations programmatically by making a POST request to the /simulate
REST API endpoint or tenderly_simulateTransaction
RPC, passing transaction details. This helps verify the success of a transaction in a controlled environment before it’s sent to the network.
Can I create a UI that shows gas estimates for user transactions using the Tenderly API?
Yes, you can integrate the gas estimation feature of Tenderly’s API into your UI to show users the estimated gas cost for their transactions before they confirm.
Alternatively, you can use tenderly_estimateGas
and tenderly_estimateGasBundle
.
How can I simulate invalid or out-of-bound inputs to verify contract resilience in various edge cases?
You can simulate function calls with invalid or out-of-bound inputs by setting custom input values in your simulation requests. This allows you to test how your contract handles edge cases and prevents potential vulnerabilities.
Can I simulate flash loan attacks or multi-contract interaction vulnerabilities?
Yes, you can simulate complex transactions such as flash loan attacks or interactions across multiple contracts by bundling the transactions in one simulation. This is helpful in testing for vulnerabilities in DeFi protocols.
How can I simulate cross-contract interactions and ensure transaction flow correctness?
By bundling transactions in a single simulation, you can test cross-contract interactions and verify that the transaction flow behaves correctly across multiple contracts. This is critical for dApps that rely on complex contract interactions.
How can I bundle multiple user actions into a single simulation to provide feedback on complex flows?
You can bundle multiple user actions by simulating them as part of a single bundled simulation. This allows you to provide feedback on complex transaction flows that involve multiple interactions in your dApp.