> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenderly.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Investigating a Failed Transaction

> Trace a reverted transaction to its root cause using the call trace, Debugger, and Evaluate, then verify the fix by re-simulating it.

In this guide, we'll investigate the root cause of transaction failure and verify the fix.

We'll look into a [Uniswap transaction](https://www.tdly.co/tx/1/0xbe082dcc8ae59868f5b2330173902bb88c6643b5c2fdf0d8a9f43d03dbca0c36). This transaction attempts to `swapExactTokensForTokens`.

<Steps>
  ### Paste the transaction hash in search of Tenderly dashboard

  Transaction hash: `0xbe082dcc8ae59868f5b2330173902bb88c6643b5c2fdf0d8a9f43d03dbca0c36`

  ### Explore the error

  The revert happened in `swapExactTokensForTokens`, checking a condition involving `amountOutMin` that is an input parameter. It reverted with the following error message:
  Error message: `UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT`

  From the inputs section, we can see that `amountOutMin` had value `1102820622890207119`.

  <img src="https://mintcdn.com/tenderly/czz1ot21Icudd1fI/images/debugger/failed-tx-1.webp?fit=max&auto=format&n=czz1ot21Icudd1fI&q=85&s=60faadd328ed0802cab5cbd27355f910" alt="" width="1600" height="1000" data-path="images/debugger/failed-tx-1.webp" />

  ### Explore revert condition

  Hop into the [debugger view](https://dashboard.tenderly.co/tx/1/0xbe082dcc8ae59868f5b2330173902bb88c6643b5c2fdf0d8a9f43d03dbca0c36/debugger?trace=0.1). Notice that require involves `amounts[amounts.length - 1]`.

  <img src="https://mintcdn.com/tenderly/czz1ot21Icudd1fI/images/debugger/failed-tx-2.webp?fit=max&auto=format&n=czz1ot21Icudd1fI&q=85&s=cad0f9f5a94de5451f69b7872c08f7cf" alt="" width="1600" height="1000" data-path="images/debugger/failed-tx-2.webp" />

  ### Evaluate the expression

  To get the value of this expression, you can use Evaluate:

  1. Make sure debugger is at the line of revert,
  2. Paste the expression \`amounts\[amounts.length - 1],
  3. press "Evaluate" button.

  The value is:
  The value is `1029855063181377015`.

  <img src="https://mintcdn.com/tenderly/czz1ot21Icudd1fI/images/debugger/failed-tx-3.webp?fit=max&auto=format&n=czz1ot21Icudd1fI&q=85&s=e69eca76680bc148c1ef6e31e7ba4d8a" alt="" width="1600" height="1000" data-path="images/debugger/failed-tx-3.webp" />

  ### Obtain the value from call information

  You can also extract the value of the expression in question by analyzing the function that produced the value:

  1. Move the debugger to the [`getAmountsOut`](https://dashboard.tenderly.co/tx/1/0xbe082dcc8ae59868f5b2330173902bb88c6643b5c2fdf0d8a9f43d03dbca0c36/debugger?trace=0.0) from the Execution trace on the left
  2. Find the `output` in the lower pane
  3. Since the expression `amounts[amounts.length - 1]` gets the last element of the array, we conclude that the value in question is `1029855063181377015`.

  <img src="https://mintcdn.com/tenderly/czz1ot21Icudd1fI/images/debugger/failed-tx-4.webp?fit=max&auto=format&n=czz1ot21Icudd1fI&q=85&s=2f6b1b03a2840f8d7a1e4d5eae7afb34" alt="" width="1600" height="1000" data-path="images/debugger/failed-tx-4.webp" />

  ### Potential solution

  This transaction would have succeeded if the value of `amountOutMin` was `1029855063181377015`.

  ### Verifying the solution

  To verify the solution, click the "Re-Simulate" button:

  1. Paste the value `1029855063181377015` to the second argument
  2. Click **Simulate**.

  The simulation has succeeded, meaning we found the correct argument value.

  <Info>
    Swap transactions are time-sensitive, they take into account the `block.timestamp` value.
    Simulations are by default executed on the original block and at the original timestamp.
    Only if you need custom block and timestamp values, you can use block header overrides for that purpose.
  </Info>
</Steps>
