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
Ethereum Mainnet
Hoodi Testnet
Solidity integration
Use a minimal interface and pass the address for your network to the constructor:
// 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 for more details.
Last updated