---
eip: 3540
label: EIP-3540
title: EOF - EVM Object Format v1
status: Stagnant
type: Standards Track
category: Core
created: 2021-03-16
requires: 3541, 3860
official: https://eips.ethereum.org/EIPS/eip-3540
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3540.md
canonical: https://eips.huatuo.xyz/eip-3540/
lang: en
tldr: Defines EOF, a versioned container for EVM bytecode starting with 0xEF00 that separates code from data and is validated once at deploy time, laying the groundwork for a cleaner EVM.
tags: [evm, eof, bytecode, core, validation]
---

# EIP-3540: EOF - EVM Object Format v1

> EOF is an extensible and versioned container format for EVM bytecode with a once-off validation at deploy time.

**TL;DR:** Defines EOF, a versioned container for EVM bytecode starting with 0xEF00 that separates code from data and is validated once at deploy time, laying the groundwork for a cleaner EVM.

## What problem does it solve?

Deployed EVM bytecode today is an unstructured blob. There is no version field and no boundary between code and data, so clients must re-run `JUMPDEST` analysis before execution to find valid jump targets. Static analysers and L2 fraud-proof systems cannot easily tell instructions from embedded constants. And because any byte pattern might be live code, adding or removing EVM features without breaking old contracts is very hard.

EIP-3540 introduces the **EVM Object Format (EOF)**: a simple container with a version number and typed sections, checked once when the contract is created. Anything that passes validation can be trusted to be well-formed forever after.

## How it works

Code that starts with the magic bytes `0xEF00` is EOF; anything else is *legacy* code and behaves as before. [EIP-3541](/eip-3541/) (London) already forbids deploying new code that starts with `0xEF`, so no existing contract can be misread as EOF.

An EOF v1 container looks like:

```
header:
  EF00 01                      magic + version 1
  01 <type_size>               type section (4 bytes per code section)
  02 <n> <code_size>+          one or more code sections
  [03 <n> <container_size>+]   optional nested containers
  FF <data_size>               data section
  00                           header terminator
body:
  types | code sections | containers | data
```

Each type entry records a code section's inputs, outputs and max stack increase. Sizes are fixed-width big-endian integers, and the total container size is capped at `MAX_INITCODE_SIZE` from [EIP-3860](/eip-3860/).

Execution changes for EOF contracts:

- Execution starts at code section 0.
- `CODESIZE`, `CODECOPY`, `EXTCODE*`, `GAS` and the legacy `CALL` family are rejected by validation; replacements come in companion EIPs.
- An EOF contract may only `DELEGATECALL` other EOF contracts, so EOF code can never be self-destructed through a delegated call.
- Legacy code that inspects an EOF account sees just `EF00`: `EXTCODESIZE` returns 2.

## Sample code

A minimal header parser in TypeScript (no body validation):

```ts
function parseEofHeader(code: Uint8Array) {
  if (code[0] !== 0xef || code[1] !== 0x00) return null; // legacy code
  const version = code[2];
  let i = 3;
  const u16 = () => (code[i++] << 8) | code[i++];
  if (code[i++] !== 0x01) throw new Error("expected type section");
  const typeSize = u16();
  if (code[i++] !== 0x02) throw new Error("expected code section");
  const numCode = u16();
  const codeSizes = Array.from({ length: numCode }, u16);
  if (typeSize !== numCode * 4) throw new Error("type/code mismatch");
  return { version, typeSize, codeSizes, rest: i };
}
```

## Things to know

- Status is **Stagnant**. EOF has not been activated on Ethereum mainnet; it was considered for a network upgrade and then left out. Legacy bytecode remains the only format in use.
- EOF is a bundle of EIPs. This one defines the container; validation, functions, stack checks and new instructions are in others such as [EIP-3670](/eip-3670/), [EIP-4750](/eip-4750/) and [EIP-5450](/eip-5450/). [EIP-7692](/eip-7692/) is the meta-EIP that lists the full set.
- The spec must not be enabled on a chain that already holds code starting with `0xEF00` that is not valid EOF.
- If you write compilers or analysers, EOF's code/data split removes the need for jumpdest analysis; for ordinary Solidity developers nothing changes unless EOF ships.


---

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