> For the complete documentation index, see [llms.txt](https://docs.oogabooga.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oogabooga.io/developers/swap-api/troubleshooting.md).

# 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.oogabooga.io/developers/swap-api/troubleshooting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
