EIP-7843 Slot number lookup opcode SLOTNUM (SLOTNUM Opcode)

No call decision · EVM & execution · EIP status Last Call · created 2024-12-06

Adds a new opcode SLOTNUM (0x4b) to the EVM, letting a smart contract read the current block's slot number directly for a gas cost of 2.

Why it is needed

There are currently two ways for a smart contract to determine the current slot number. The first is to compute it from the block timestamp, which requires hardcoding the length of a slot into the contract code. If Ethereum later changes the slot length, all such contracts will then behave incorrectly. The second is to pass the slot number in as calldata and prove it against the beacon block root (using EIP-4788), but the gas cost is high enough that developers end up falling back on the first method anyway. This EIP chooses to hide the slot length from the application. The consensus layer client, which already knows the slot number, computes the value and passes it down, and the contract reads that value with a single opcode. This opens the door to changing the slot length in the future.

What changes

Today

After EIP-7843

Who is affected

In depth

Opcode definition and output

The new opcode SLOTNUM is added at 0x4b. It takes no input and pushes one element onto the stack. The value pushed, slotNumber, is the slot number corresponding to the current block, encoded as a big-endian uint64. Previously there was no way to obtain this value directly within the EVM; it had to be back-calculated from the block timestamp, or received as calldata and proven against the beacon block root per EIP-4788. SLOTNUM adds the slot number to the family of opcodes that read block environment information, like TIMESTAMP, avoiding the drawbacks of both existing approaches (hardcoding and high gas cost).

The gas cost is a fixed 2

The gas cost of SLOTNUM is a fixed fee of 2. The source Rationale explains that this matches the pricing of similar opcodes in the W_base set. This pricing decision determines the practical effect of this proposal. According to the Motivation, the EIP-4788 proof method was expensive in gas, which pushed developers toward hardcoding slot length as a workaround; once the slot number can be read for 2 gas, there is no reason to resort to that workaround.

Header extension and Engine API changes

The slot number is computed in the consensus layer and passed to the execution layer through the Engine API. Two things change to make this possible. First, a slotNumber field of type uint64 is added to the block header encoding. Second, new objects ExecutionPayloadV4 and PayloadAttributesV4, which add the slotNumber field, are introduced to the Engine API, along with new methods that use these objects: engine_newPayloadV5, engine_getPayloadV6, and engine_forkchoiceUpdatedV4. In other words, this proposal does not just add a single EVM opcode; it also changes the block structure and the client-to-client communication spec.

Why compute it in the consensus layer

There is an alternative in which the execution layer computes the slot number from the timestamp. However, the source document considers it more appropriate for a value belonging to the beacon chain to be computed in the consensus layer. Since the consensus layer already computes the slot number, this also avoids the code duplication of reimplementing the same calculation in the execution layer. This design also ties into the core goal of the Motivation: abstracting the slot length, a chain parameter, away from applications and the execution layer means deployed contracts will not break even if the slot length changes later.

Impact on ZK proving

The source document explains that because SLOTNUM is similar to existing opcodes such as TIMESTAMP, it will not add complexity to proving EVM execution with ZK. Placing the slot number in the block header rather than as a parameter of engine_newPayload was also a choice made with proving in mind. When it is in the header, the block is self-contained, so there is no need to feed a value from outside the block data into the proving circuit as an extra input.

Current status and remaining variables

This EIP is currently in Last Call status, with a last-call deadline of 2026-11-01. The source document states that no backwards compatibility issues have been found (Backwards Compatibility) and that there are no security considerations (Security Considerations), and the test cases are N/A. The core developer call records provided for this explainer contain no decision to include this EIP in a specific fork. Since it has not reached final status, the details may still change.

Original EIP · ← EIPs