> For the complete documentation index, see [llms.txt](https://docs.ethgas.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ethgas.com/get-started/traders/onchain-realtime-slot-lookup.md).

# Onchain Realtime Slot Lookup

Smart contracts can query `EthgasLookahead` to check whether the current slot or a specific slot is an ETHGas realtime slot.

### Contract addresses

<table><thead><tr><th width="184.671875">Network</th><th>EthgasLookahead</th></tr></thead><tbody><tr><td>Ethereum Mainnet</td><td><a href="https://etherscan.io/address/0xdD79AEA143C4A0605963EECfae41d0ae6E619751">0xdD79AEA143C4A0605963EECfae41d0ae6E619751</a></td></tr><tr><td>Hoodi Testnet</td><td><a href="https://hoodi.etherscan.io/address/0x7bAd76D7e75e8FD199AD626a3E410Aa616E2fb2D">0x7bAd76D7e75e8FD199AD626a3E410Aa616E2fb2D</a></td></tr></tbody></table>

### Solidity integration

Use a minimal interface and pass the address for your network to the constructor:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

interface IEthgasLookahead {
    function currentSlot() external view returns (uint256);
    function isCurrentEthgasSlot() external view returns (bool);
    function isEthgasSlot(uint256 slot) external view returns (bool);
}

contract RealtimeExample {
    IEthgasLookahead public immutable lookahead;

    constructor(address lookaheadAddress) {
        lookahead = IEthgasLookahead(lookaheadAddress);
    }

    function execute() external {
        require(lookahead.isCurrentEthgasSlot(), "Not an ETHGas slot");
        // Your realtime-slot logic here.
        // ...
    }

    function isRealtimeSlot(uint256 slot) external view returns (bool) {
        return lookahead.isEthgasSlot(slot);
    }
}
```

`isCurrentEthgasSlot()` checks the slot derived from the executing block's timestamp. Use `currentSlot()` to read that slot number, or `isEthgasSlot(slot)` to query a specific consensus slot number. Do not pass `block.number`: block numbers and slot numbers are different.

The result reflects the lookahead bitmap currently published on-chain. `true` means the slot is marked as an ETHGas realtime slot. The lookahead is updated one epoch in advance.

### Use case: lower swap fees in realtime pools

A Uniswap v4 pool can use a hook that queries `EthgasLookahead` to apply a lower swap fee during ETHGas realtime slots. When `isCurrentEthgasSlot()` returns `true`, the hook applies the pool's realtime fee; otherwise, it applies the pool's standard fee. This lets users benefit from lower swap fees when their swaps execute in realtime slots.

The fee discount is implemented by the pool's hook; querying the lookahead contract alone does not change fees. See [Uniswap Realtime Pools](https://docs.ethgas.com/get-started/traders/uniswap-realtime-pools) for more details.


---

# 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.ethgas.com/get-started/traders/onchain-realtime-slot-lookup.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.
