---
eip: 2327
label: EIP-2327
title: BEGINDATA opcode
status: Stagnant
type: Standards Track
category: Core
created: 2019-10-28
official: https://eips.ethereum.org/EIPS/eip-2327
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2327.md
canonical: https://eips.huatuo.xyz/eip-2327/
lang: en
tldr: "Proposed a BEGINDATA opcode (0xb6) that marks the rest of a contract's bytecode as data, so it can never be jumped into or mistaken for instructions."
tags: [evm, opcode, bytecode, core]
---

# EIP-2327: BEGINDATA opcode

> Introduces a new opcode BEGINDATA, which indicates that the remaining bytes of the contract should be regarded as data rather than contract code and cannot be executed.

**TL;DR:** Proposed a BEGINDATA opcode (0xb6) that marks the rest of a contract's bytecode as data, so it can never be jumped into or mistaken for instructions.

## What problem does it solve?

Contracts routinely carry raw data inside their bytecode: constructor arguments, constants, compiler metadata, and, during deployment, the runtime code itself. The EVM has no way to tell this data apart from real instructions. Clients still scan it during `JUMPDEST` analysis, a stray `0x5b` byte inside data is a valid jump target, and disassemblers, explorers and debuggers render the data as a wall of nonsense opcodes.

EIP-2327 proposes a simple marker: everything after the first `BEGINDATA` is data, not code. That makes static analysis easier, makes it impossible to jump into data, and lets tools display bytecode honestly.

## How it works

- A new opcode `BEGINDATA` at byte `0xb6` (chosen to match the earlier [EIP-615](/eip-615/) proposal).
- **Jump analysis stops** at the first `BEGINDATA`. Any jump to a position at or after it fails with a bad-jump-destination error, even if the byte there is `0x5b`.
- **Executing** `BEGINDATA` behaves like `STOP` and costs 0 gas.
- Data after the marker is still readable: `CODECOPY` and `EXTCODECOPY` work as before, and `CODESIZE` / `EXTCODESIZE` still report the full length.

The spec's two test cases capture the whole behaviour:

1. Jumping to a `0x5b` byte located after `BEGINDATA` must fail.
2. Reaching `BEGINDATA` during execution stops the current call frame.

The motivation also mentions off-chain uses: systems that check whether code follows a certain pattern (the spec cites Optimism) would no longer need a full `JUMPDEST` analysis to prove that data is never executed.

## Sample code

How a client's jump-destination analysis would change (pseudocode):

```python
BEGINDATA = 0xB6
JUMPDEST = 0x5B

def valid_jumpdests(code: bytes) -> set[int]:
    dests, pc = set(), 0
    while pc < len(code):
        op = code[pc]
        if op == BEGINDATA:
            break                      # everything after this is data
        if op == JUMPDEST:
            dests.add(pc)
        if 0x60 <= op <= 0x7F:         # PUSH1..PUSH32: skip immediate bytes
            pc += op - 0x5F
        pc += 1
    return dests
```

A contract layout using the marker (illustrative):

```
<runtime code ...> STOP
BEGINDATA                 ; 0xb6
<constants / metadata>    ; readable via CODECOPY, never executable
```

## Things to know

- **Status: Stagnant.** The proposal was never scheduled for a network upgrade, and `0xb6` is not a `BEGINDATA` opcode on Ethereum mainnet.
- Backwards compatibility hinges on whether any deployed contract relies on executing bytes that would sit after a `0xb6`. The spec notes Solidity never generated such code, but contracts produced by other means would have needed checking.
- The rationale admits that treating `BEGINDATA` as `STOP` is somewhat arbitrary; aborting with an out-of-gas style error was the alternative.
- The broader goal of separating code from data was later pursued by the EVM Object Format proposals ([EIP-3540](/eip-3540/), [EIP-3670](/eip-3670/)), which use explicit code and data sections instead of an in-line marker.


---

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