Simulate via RPC
Node RPC allows you to read blockchain data and send transactions. But you can also simulate transactions on the Node. The advantage of simulating via RPC is that you can perform all these operations through a single RPC URL.Simulations via RPC or API are only available on supported networks. Check out the list of supported networks.
example
tenderly_simulateTransaction method. See RPC reference.
Example
- request
- response.json
request
Simulate via API
Use the simulate API endpoint to simulate a single transaction with different parameters.To use Simulations on Virtual Environments, we recommend the Simulate RPC and Bundle Simulate RPC.
Otherwise, you may use Virtual Environments Simulation API.
Simulation API endpoint on public network
Simulation API endpoint on a Virtual Environment
Request payload
Send aPOST request to the API endpoint. For full details on the request payload, see the See API reference.
The simulated payload is similar to the eth_call JSON RPC call.
The fields below are required:
network_id(string): ID of the network where you want to run the simulation.block_number(number): “latest” or the block number to be used for the simulation.to(string): The recipient address of the transaction.from(string): Address initiating the transaction.input(string): Encoded contract method call data.gas(number): Amount of gas provided for the simulation.
You can specify any sender address in the
from field. Since Tenderly simulates unsigned transactions, you don’t need
to own an account’s private key to simulate transactions from a specific sender.simulation_type, which can be full, quick, or ABI. This field is not required since the default is set to full. Learn more about Simulation Modes.
When making API requests, add the X-Access-Key header with the value being the access token.
Example
Make sure to store the access key securely in a .env file.
- request.ts
- response.json
request.ts
Explore use cases
- Preview transaction outcomes: Identify and fix issues that could cause transactions to fail.
- Asset and balance changes: Get exact dollar values for all balance and asset changes that will happen.
- Gas estimation: Accurately predict the gas costs before sending the transaction.
- State overrides: Modify blockchain conditions like timestamps and contract data to test different scenarios.