Simulate Transactions on TestNets
Transaction simulations are supported on Virtual TestNets. You can simulate transactions form the Dashboard UI or programmatically using RPC.
Simulate from the Dashboard
To simulate a transaction from the Dashboard, go to Virtual TestNets and click Simulate from the left-hand menu. Simulated transactions are visible only within the TestNet dashboard and won’t be visible in the Public Explorer. You can use the Simulator in the following ways:
- Debug smart contracts errors, using Edit Source to check your bugfix.
- Call contracts to get a sense of states without persisting transactions to the network.
- Set up desired contract states using State Overrides, to evaluate the execution under conditions that aren’t and shouldn’t be present on the chain.
- Build proof of concept transactions to validate testing scenarios.
Simulate via RPC
Transactions on TestNets can also be simulated using our the RPC methods tenderly_simulate
and tenderly_simulateBundle
.
We recommend integrating the Simulation RPC, but it’s possible to use Simulation REST API.
The example code below runs a simulation that uses state overrides to mint DAI.
- Sender address:
0xe2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2
. - DAI contract address:
0x6b175474e89094c44da98b954eedeac495271d0f
- State override arguments:
DAI(0x6b175474e89094c44da98b954eedeac495271d0f).wards[0xe2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2] = 1
Explore this guide to learn more about simulating with state overrides.
# simulate DAI minting by 0xe2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2
# 0xf1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1 gets the minted DAI
# Simulated on the latest block
VIRTUAL_TESTNET_RPC=RPC_LINK_HERE
curl $VIRTUAL_TESTNET_RPC \
-X POST \
-H "Content-Type: application/json" \
-d \
'{
"id":0,
"jsonrpc":"2.0",
"method":"tenderly_simulateTransaction",
"params":[
{
"from":"0xe2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2",
"to":"0x6b175474e89094c44da98b954eedeac495271d0f",
"gas":"0x7a1200",
"data":"0x40c10f19000000000000000000000000f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f10000000000000000000000000000000000000000000000001bc16d674ec80000"
},
"latest",
{
"0x6b175474e89094c44da98b954eedeac495271d0f":{
"stateDiff":{
"0xedd7d04419e9c48ceb6055956cbb4e2091ae310313a4d1fa7cbcfe7561616e03":"0x0000000000000000000000000000000000000000000000000000000000000001"
},
"balance": "0xFFFFFF"
}
}
]
}'
Simulate transactions via client libraries
To simulate transactions via Ethers and Viem, check out the following example: