# Troubleshooting

## Debugging Transaction Failures

EVM execution environments often provide limited ways to figure how exactly a transaction failed to execute.&#x20;

[Foundry](https://book.getfoundry.sh/getting-started/installation) provides a useful command:

```bash
cast run 0x8e14deeb46f1757b21a0fcb4badb0a5296c7a2d20ec3963732214ed74cb3c03e --rpc-url https://bartio.rpc.berachain.com
```

This shows a breakdown of the transaction execution and the different contract interactions.

Assuming the transaction failed, the most probable error signature would be `0x71c4efed` (`SlippageExceeded`).&#x20;

You can look up the full list of errors in the `OBRouter` Reference.

Alternatively if the error is not found on the table, foundry also provides [cast-4byte](https://book.getfoundry.sh/reference/cast/cast-4byte?highlight=4byte#cast-4byte) which can decode the error if it is already present in their lookup table:

```bash
cast 4byte 0x71c4efed
```

***

## OutOfGas Transactions

We've identified that bArtio's gas estimation for transactions can sometimes be inaccurate, leading to failures due to insufficient gas. When reviewing such transactions on a block explorer or using debugging methods (described above), you'll notice that the failures are attributed to inadequate gas provision.

By default, viem and wagmi will always try to estimate gas from the RPC if no gas limit is set to the transaction. This gas estimation often leads to incorrect estimates that lead to transactions failing with`OutOfGas`.&#x20;

> \[OutOfGas] EvmError: OutOfGas

To address this issue, we’ve implemented a solution in our frontend and recommend other integrators do the same. The approach involves manually estimating the transaction gas using the RPC, then submitting the swap transaction with an additional buffer added to the estimated gas value.

We suggest applying a buffer of **10%-20%** on top of the RPC's returned gas estimate. This method has proven effective in mitigating `OutOfGas` errors and ensuring smoother transaction execution.

Below is an example of through viem:

```typescript
const gas = await publicClient.estimateGas({
  account: tx.from as Address,
  to: tx.to as Address,
  data: tx.data as `0x${string}`,
  value: tx.value ? BigInt(tx.value) : 0n,
});

// Add 10% gas buffer
const gasWithBuffer = (gas * 11) / 10;

await client.sendTransaction({
  account: tx.from as Address,
  to: tx.to as Address,
  data: tx.data as `0x${string}`,
  value: tx.value ? BigInt(tx.value) : 0n,
  gas: gasWithBuffer,
});
```

***

## Transaction Calldata Missing on Swap API[​](https://docs.oogabooga.io/api/troubleshooting#tx-calldata-missing-on-the-swap-api) <a href="#tx-calldata-missing-on-the-swap-api" id="tx-calldata-missing-on-the-swap-api"></a>

If the `swap` endpoint on the API does not return the transaction calldata. This is because a `to` parameter needs to be provided in order for the calldata to be constructed, otherwise `OBRouter` does not know where to send outputted tokens.
