---
eip: 7843
label: EIP-7843
title: SLOTNUM opcode
status: Last Call
type: Standards Track
category: Core
created: 2024-12-06
official: https://eips.ethereum.org/EIPS/eip-7843
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7843.md
canonical: https://eips.huatuo.xyz/eip-7843/
lang: en
tldr: Adds a SLOTNUM opcode (0x4b) that returns the beacon-chain slot number of the current block, so contracts no longer hardcode the 12-second slot length.
tags: [evm, opcode, consensus, slots, core]
---

# EIP-7843: SLOTNUM opcode

> Opcode to get the current slot number

**TL;DR:** Adds a SLOTNUM opcode (0x4b) that returns the beacon-chain slot number of the current block, so contracts no longer hardcode the 12-second slot length.

## What problem does it solve?

Since the Merge, every Ethereum block belongs to a beacon-chain slot. Some contracts care about the slot number: for example, anything that lines up with validator duties, preconfirmations or beacon-chain proofs. Today they have two options:

1. **Compute it from `block.timestamp`** using a hardcoded genesis time and slot length. Cheap, but it silently breaks if the slot length ever changes, and shortening slots is under active discussion.
2. **Pass the slot in calldata and prove it** against the beacon block root exposed by [EIP-4788](/eip-4788/). Robust, but expensive, so people tend to use option 1 anyway.

EIP-7843 removes the dilemma by exposing the slot number directly.

## How it works

- New opcode **`SLOTNUM` at `0x4b`**. It takes no inputs and pushes one word: the current block's slot number, a `uint64`.
- Gas cost is a flat **2**, like other simple block-context opcodes (`TIMESTAMP`, `NUMBER`, ...).
- The consensus layer, which already knows the slot, passes it to the execution layer via the Engine API: new `ExecutionPayloadV4` and `PayloadAttributesV4` objects with a `slotNumber` field, used by `engine_newPayloadV5`, `engine_getPayloadV6` and `engine_forkchoiceUpdatedV4`.
- The execution block header gains a `slotNumber` field, so each block is self-contained. Light clients and ZK-EVM provers need no extra inputs, much as for `TIMESTAMP`.

Computing the value in the consensus layer avoids duplicating the slot/timestamp logic in execution clients, and leaves room to change slot timing later.

## Sample code

Raw EVM bytecode for a function that just returns the slot number (no compiler support is needed to see the semantics):

```text
4b        SLOTNUM          // stack: [slot]
5f        PUSH0            // stack: [0, slot]
52        MSTORE           // memory[0..32] = slot
6020      PUSH1 0x20
5f        PUSH0
f3        RETURN           // return 32 bytes
```

Execution-client pseudocode:

```python
def slotnum(evm):
    charge_gas(evm, 2)                       # same tier as TIMESTAMP
    evm.stack.push(U256(evm.block_env.slot_number))  # from the block header
```

The fragile pattern it replaces:

```solidity
// Breaks if slot duration changes.
uint256 constant GENESIS = 1606824023;
uint256 constant SLOT_SECONDS = 12;
uint256 slot = (block.timestamp - GENESIS) / SLOT_SECONDS;
```

## Things to know

- Status: **Last Call**, with a deadline of 2026-11-01 in the spec. It is not yet Final, and the opcode is not live until a network upgrade activates it.
- Engine API method and object version numbers in the spec depend on what other upgrades ship alongside it and may be renumbered.
- Solidity and other compilers need to add support before contracts can use it without hand-written bytecode.
- Header extensions affect anyone who RLP-decodes block headers directly.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7843
