Easily Debug Failed Transactions
By default, transactions executed via API donโ€™t persist in Tenderly and are not visible in the dashboard. When you execute Simulations you probably need to examine why they failed.
When running a transaction Simulation you can provide the save_if_fails flag. In case of a failure, it will be persisted in the Tenderly Dashboard.
If you need to save the Simulation of a successfully executed transaction, you can set the save flag (false by default).
Additionally, the response you receive will contain simulation ID (simulation.id), so you can generate a link directly to the Tenderly Debugger. This would help you speed up the time needed to understand and fix the bug or any other issue that is present in the smart contract.
1
...
2
โ€‹
3
const body = {
4
"network_id": "1",
5
"from": senderAddr,
6
"to": contract.address,
7
"input": unsignedTx.data,
8
"gas": 21204,
9
"gas_price": "0",
10
"value": 0,
11
"save_if_fails": true
12
}
13
โ€‹
14
const opts = {
15
headers: {
16
'content-type': 'application/JSON',
17
'X-Access-Key': TENDERLY_ACCESS_KEY,
18
}
19
}
20
const resp = await axios.post(apiURL, body, opts);
21
โ€‹
22
if simulation.status == "failed" {
23
const link = `https://dashboard.tenderly.co/project/${TENDERLY_PROJECT_SLUG}/simulator/${resp.data.simulation.id}`
24
25
// trigger sentry, log error, make the test fail if in test
26
}
Copied!
Copy link