> For the complete documentation index, see [llms.txt](https://docs.pharos.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pharos.xyz/getting-started/faqs.md).

# FAQs

## Problem Explanation

Ethereum's execution model deducts the full gas limit at the start of execution and refunds a portion of the gas at the end if applicable. However, if the gas limit is set too tightly (equal to the actual gas used before refunds), the refund cannot be processed, and the transaction fails with an out-of-gas error.

### Key reasons why this happens:

* Gas is initially reserved: The EVM deducts the full gas limit at the beginning of execution.
* Gas refund happens at the end: If a contract includes operations that delete storage variables (e.g., `SELFDESTRUCT`, `SSTORE` clearing a slot), the gas refund is only applied after execution completes.
* If gas runs out before refunding, the transaction fails because the EVM does not get a chance to apply the refund.

### Example Scenario

Below is an example of a Uniswap V3 transaction deployed on Pharos Devnet, where the actual gas used was 4,618,680:\
<https://pharosscan.xyz/tx/0x205a123820ad75de162ba3cabe06183d34377e239c3a8f6f18636d4c87b3a524>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdlS2EDw_PPNgBSFYdTOVA5JzeQhlRYrIW2Lu16Gpqyi0SfU7Ezqg9sqm0VFjp29kWSxMPBBBVUfZSq_nARMBzcdzoRg4Bm8t8XCLik9g064UrpKap8jvmCLj2r4LgZCdIkozyD?key=77gsDOQDxHb7PI4vhmETXLk-" alt=""><figcaption></figcaption></figure>

However, since the gas limit was set exactly equal to the gas used, the transaction failed.

To verify this behavior, we deployed the same transaction on Ethereum Sepolia Testnet, and observed the same failure due to the gas limit issue:\
<https://sepolia.etherscan.io/tx/0x55af4ffe714ad075c6f979e7f89670e1498647abedd6ea7112e1c6339cef64aa>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcaYqtP6uujRgownbFTRVNX8cVBy-vSrNYSPlKcnHIFPEvWwdcMf66bG4wEZC5z4nFfNQBc1j2GWJaYO0PQIqw0ZMixxRLPNfxxbmyw_Fkhy7KBX4_9aHoSUw8k8VHqhMwP7c8IGw?key=77gsDOQDxHb7PI4vhmETXLk-" alt=""><figcaption></figcaption></figure>

To ensure the transaction executes successfully, we need to set the gas limit slightly higher than the expected gas usage.\
<https://pharosscan.xyz/tx/0x6ccf7f593f5783414b3726e147319e74046526d800b325110bdf81ac3012aa5e>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc-e8YrFFvEnvTLIr6JaqRBpA_grGLy4Uj4tgLKeFdpop40cqv0QFVT-vOsgIp2RqNQXH-zByGNlipf5iO_z24G6hQhr4WfrAMdcfsfFtjtvbS58xlQrLtebaeyGkz1bhRqCKuZ5g?key=77gsDOQDxHb7PI4vhmETXLk-" alt=""><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pharos.xyz/getting-started/faqs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
