{"eip":7834,"title":"Separate Metadata Section for EOF","description":"Introduce a new separate metadata section to the EOF","authors":["Kaan Uzdogan (@kuzdogan)","Marco Castignoli (@marcocastignoli)","Manuel Wedler (@manuelwedler)"],"status":"Review","type":"Standards Track","category":"Core","created":"2024-12-06","requires":[3540],"discussionsTo":"https://ethereum-magicians.org/t/eip-7834-separate-metadata-section-for-eof/22138","repo":"EIPs","label":"EIP-7834","officialUrl":"https://eips.ethereum.org/EIPS/eip-7834","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7834.md","url":"https://eips.huatuo.xyz/eip-7834/","tldr":{"en":"Proposes an optional, code-unreachable metadata section in EOF containers so compiler metadata no longer shifts executable bytecode or confuses source verification.","ja":"コンパイラのメタデータが実行可能バイトコードをずらしたり、ソース検証を混乱させたりしないよう、EOF コンテナに、コードから到達できない任意のメタデータセクションを追加することを提案する。","ko":"컴파일러 메타데이터가 실행 가능한 바이트코드를 밀어내거나 소스 검증을 혼란스럽게 하지 않도록, EOF 컨테이너에 코드가 접근할 수 없는 선택적 메타데이터 섹션을 두자고 제안한다.","zh":"提议在 EOF 容器中增加一个可选的、代码无法访问的元数据部分，使编译器元数据不再移动可执行字节码，也不再干扰源码验证。"},"tags":["eof","evm","bytecode","verification","compiler"],"explainers":{"en":{"lang":"en","tldr":"Proposes an optional, code-unreachable metadata section in EOF containers so compiler metadata no longer shifts executable bytecode or confuses source verification.","tags":["eof","evm","bytecode","verification","compiler"],"related":[3540,7692,7480],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7834/","markdown":"## What problem does it solve?\n\nSolidity and Vyper append metadata to contract bytecode by default: the compiler version and, for Solidity, an IPFS or Swarm hash of the metadata JSON, CBOR-encoded and followed by a 2-byte length. Source verifiers such as block explorers must strip it before comparing on-chain code with a fresh compile. Because legacy bytecode has no structure, they rely on heuristics, and factory contracts with nested bytecode make it worse.\n\nThe EVM Object Format ([EIP-3540](/eip-3540/)) adds structure: separate code and data sections. But with no dedicated place for metadata, compilers would put it in the data section, where:\n\n1. it is still hard to tell apart from real data;\n2. a change in metadata size shifts data offsets (e.g. `DATALOADN` immediates from [EIP-7480](/eip-7480/)), so two contracts with identical logic produce different code;\n3. code could, in theory, read it.\n\n## How it works\n\nEIP-7834 adds an **optional `metadata_section`** to the EOF container body, placed after any container sections and **before** the data section, with a matching header entry:\n\n| Header field | Size | Value |\n| --- | --- | --- |\n| `kind_metadata` | 1 byte | `0x05` |\n| `metadata_size` | 2 bytes | `0x0001`–`0xFFFF`, big-endian |\n\nThe header entry sits just before `kind_data` (`0xff`). Code cannot reach the section, and the EIP does not define its encoding; compilers are expected to keep using CBOR.\n\nWhy before the data section? Data can grow during deployment (EOF allows appending to data), which would otherwise move the metadata. Why `0x05` instead of the next free kind? To ease adoption by existing EOF tooling.\n\n## Sample code\n\nContainer grammar with the new optional fields:\n\n```text\nheader :=\n    magic, version,\n    kind_type, type_size,\n    kind_code, num_code_sections, code_size+,\n    [kind_container, num_container_sections, container_size+,]\n    [kind_metadata, metadata_size,]          ; NEW, 0x05\n    kind_data, data_size,\n    terminator\nbody := types_section, code_section+, container_section*,\n        [metadata_section],                  ; NEW\n        data_section\n```\n\nA verifier can then compare everything except the metadata bytes (TypeScript sketch):\n\n```ts\nfunction stripMetadata(container: EofContainer): Uint8Array {\n  // With a dedicated section, no heuristics are needed:\n  return container.serialize({ omitSections: [\"metadata\"] });\n}\nconst match = equal(stripMetadata(onchain), stripMetadata(compiled));\n```\n\n`EofContainer` here is a hypothetical parser type, not a specific library.\n\n## Things to know\n\n- **Status: Review.** It extends EOF, which itself is **Stagnant**: EOF ([EIP-3540](/eip-3540/), meta [EIP-7692](/eip-7692/)) was removed from the Fusaka upgrade and is not active on mainnet. This EIP only matters if EOF is revived.\n- No backwards compatibility concerns, since EOF was never deployed.\n- Legacy (non-EOF) contracts are unaffected; verifiers still need today's heuristics for them.\n"},"ja":{"lang":"ja","tldr":"コンパイラのメタデータが実行可能バイトコードをずらしたり、ソース検証を混乱させたりしないよう、EOF コンテナに、コードから到達できない任意のメタデータセクションを追加することを提案する。","tags":["eof","evm","bytecode","verification","compiler"],"related":[3540,7692,7480],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7834/","markdown":"## 何を解決するのか\n\nSolidity と Vyper は、デフォルトでコントラクトのバイトコードの末尾にメタデータを付加します。コンパイラのバージョンと、Solidity の場合はメタデータ JSON の IPFS または Swarm ハッシュを CBOR エンコードし、その後ろに 2 バイトの長さを置いたものです。ブロックエクスプローラーのようなソース検証ツールは、オンチェーンのコードと新しくコンパイルした結果を比較する前に、これを取り除かなければなりません。レガシーのバイトコードには構造がないため、ヒューリスティックに頼ることになり、ネストしたバイトコードを持つファクトリーコントラクトではさらに悪化します。\n\nEVM Object Format（[EIP-3540](/eip-3540/)）は構造を加えます。コードセクションとデータセクションが分かれます。しかしメタデータ専用の置き場所がないと、コンパイラはそれをデータセクションに入れることになり、次のような問題が起きます。\n\n1. 本物のデータとの区別が依然として難しい。\n2. メタデータのサイズが変わるとデータのオフセット（たとえば [EIP-7480](/eip-7480/) の `DATALOADN` の即値）がずれ、ロジックが同一の 2 つのコントラクトが異なるコードになる。\n3. 理論上は、コードがそれを読めてしまう。\n\n## 仕組み\n\nEIP-7834 は、EOF コンテナの本体に**任意の `metadata_section`** を追加します。位置はコンテナセクションの後、かつデータセクションの**前**で、対応するヘッダーエントリーも加わります。\n\n| ヘッダーフィールド | サイズ | 値 |\n| --- | --- | --- |\n| `kind_metadata` | 1 バイト | `0x05` |\n| `metadata_size` | 2 バイト | `0x0001`〜`0xFFFF`、ビッグエンディアン |\n\nヘッダーエントリーは `kind_data`（`0xff`）の直前に置かれます。コードはこのセクションに到達できず、この EIP はそのエンコーディングを定義しません。コンパイラは引き続き CBOR を使うと想定されています。\n\nなぜデータセクションの前なのか。データはデプロイ中に増えることがあり（EOF ではデータへの追記が許されています）、そうでなければメタデータが動いてしまうためです。なぜ次の空き kind ではなく `0x05` なのか。既存の EOF ツールでの採用を容易にするためです。\n\n## サンプルコード\n\n新しい任意フィールドを含むコンテナの文法:\n\n```text\nheader :=\n    magic, version,\n    kind_type, type_size,\n    kind_code, num_code_sections, code_size+,\n    [kind_container, num_container_sections, container_size+,]\n    [kind_metadata, metadata_size,]          ; NEW, 0x05\n    kind_data, data_size,\n    terminator\nbody := types_section, code_section+, container_section*,\n        [metadata_section],                  ; NEW\n        data_section\n```\n\nこれにより、検証側はメタデータのバイト以外のすべてを比較できます（TypeScript のスケッチ）:\n\n```ts\nfunction stripMetadata(container: EofContainer): Uint8Array {\n  // With a dedicated section, no heuristics are needed:\n  return container.serialize({ omitSections: [\"metadata\"] });\n}\nconst match = equal(stripMetadata(onchain), stripMetadata(compiled));\n```\n\nここでの `EofContainer` は仮想的なパーサー型であり、特定のライブラリではありません。\n\n## 知っておくべきこと\n\n- **ステータス: Review。** これは EOF を拡張するもので、EOF 自体は **Stagnant** です。EOF（[EIP-3540](/eip-3540/)、メタ EIP は [EIP-7692](/eip-7692/)）は Fusaka アップグレードから外され、メインネットでは有効ではありません。この EIP は、EOF が復活した場合にのみ意味を持ちます。\n- EOF は一度もデプロイされていないため、後方互換性の懸念はありません。\n- レガシー（EOF ではない）コントラクトには影響しません。検証側は、それらについては引き続き現在のヒューリスティックが必要です。\n"},"ko":{"lang":"ko","tldr":"컴파일러 메타데이터가 실행 가능한 바이트코드를 밀어내거나 소스 검증을 혼란스럽게 하지 않도록, EOF 컨테이너에 코드가 접근할 수 없는 선택적 메타데이터 섹션을 두자고 제안한다.","tags":["eof","evm","bytecode","verification","compiler"],"related":[3540,7692,7480],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7834/","markdown":"## 어떤 문제를 해결하나요?\n\nSolidity와 Vyper는 기본적으로 컨트랙트 바이트코드 끝에 메타데이터를 덧붙입니다. 컴파일러 버전과, Solidity의 경우 메타데이터 JSON의 IPFS 또는 Swarm 해시를 CBOR로 인코딩하고 그 뒤에 2바이트 길이를 붙인 것입니다. 블록 탐색기 같은 소스 검증기는 온체인 코드를 새로 컴파일한 결과와 비교하기 전에 이를 제거해야 합니다. 레거시 바이트코드에는 구조가 없으므로 휴리스틱에 의존하며, 중첩된 바이트코드를 가진 팩토리 컨트랙트는 상황을 더 어렵게 합니다.\n\nEVM Object Format([EIP-3540](/eip-3540/))은 구조를 더합니다. 코드 섹션과 데이터 섹션이 분리됩니다. 하지만 메타데이터를 위한 전용 자리가 없으면 컴파일러는 이를 데이터 섹션에 넣게 되고, 그러면 다음과 같은 문제가 생깁니다.\n\n1. 실제 데이터와 구분하기가 여전히 어렵습니다.\n2. 메타데이터 크기가 바뀌면 데이터 오프셋(예: [EIP-7480](/eip-7480/)의 `DATALOADN` 즉시값)이 밀려, 로직이 같은 두 컨트랙트가 서로 다른 코드를 만들어 냅니다.\n3. 이론적으로는 코드가 이를 읽을 수 있습니다.\n\n## 어떻게 동작하나요?\n\nEIP-7834는 EOF 컨테이너 본문에 **선택적 `metadata_section`**을 추가합니다. 위치는 컨테이너 섹션들 뒤, 데이터 섹션 **앞**이며, 대응하는 헤더 항목도 함께 추가됩니다.\n\n| 헤더 필드 | 크기 | 값 |\n| --- | --- | --- |\n| `kind_metadata` | 1바이트 | `0x05` |\n| `metadata_size` | 2바이트 | `0x0001`–`0xFFFF`, 빅 엔디언 |\n\n헤더 항목은 `kind_data`(`0xff`) 바로 앞에 놓입니다. 코드는 이 섹션에 접근할 수 없으며, 이 EIP는 그 인코딩을 정의하지 않습니다. 컴파일러는 계속 CBOR을 사용할 것으로 예상됩니다.\n\n왜 데이터 섹션 앞일까요? 데이터는 배포 중에 늘어날 수 있고(EOF는 데이터에 덧붙이는 것을 허용합니다), 그렇지 않으면 메타데이터가 밀려나기 때문입니다. 왜 다음 빈 kind가 아니라 `0x05`일까요? 기존 EOF 도구의 채택을 쉽게 하기 위해서입니다.\n\n## 샘플 코드\n\n새 선택 필드를 포함한 컨테이너 문법입니다.\n\n```text\nheader :=\n    magic, version,\n    kind_type, type_size,\n    kind_code, num_code_sections, code_size+,\n    [kind_container, num_container_sections, container_size+,]\n    [kind_metadata, metadata_size,]          ; NEW, 0x05\n    kind_data, data_size,\n    terminator\nbody := types_section, code_section+, container_section*,\n        [metadata_section],                  ; NEW\n        data_section\n```\n\n그러면 검증기는 메타데이터 바이트를 제외한 모든 것을 비교할 수 있습니다(TypeScript 스케치).\n\n```ts\nfunction stripMetadata(container: EofContainer): Uint8Array {\n  // With a dedicated section, no heuristics are needed:\n  return container.serialize({ omitSections: [\"metadata\"] });\n}\nconst match = equal(stripMetadata(onchain), stripMetadata(compiled));\n```\n\n여기서 `EofContainer`는 가상의 파서 타입이며 특정 라이브러리가 아닙니다.\n\n## 알아둘 점\n\n- **상태: Review.** 이는 EOF를 확장하는데, EOF 자체는 **Stagnant**입니다. EOF([EIP-3540](/eip-3540/), 메타 EIP는 [EIP-7692](/eip-7692/))는 Fusaka 업그레이드에서 제외되었고 메인넷에서 활성화되어 있지 않습니다. 이 EIP는 EOF가 되살아날 때만 의미가 있습니다.\n- EOF는 배포된 적이 없으므로 하위 호환성 문제는 없습니다.\n- 레거시(비 EOF) 컨트랙트는 영향을 받지 않으며, 검증기는 이들에 대해 여전히 현재의 휴리스틱이 필요합니다.\n"},"zh":{"lang":"zh","tldr":"提议在 EOF 容器中增加一个可选的、代码无法访问的元数据部分，使编译器元数据不再移动可执行字节码，也不再干扰源码验证。","tags":["eof","evm","bytecode","verification","compiler"],"related":[3540,7692,7480],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7834/","markdown":"## 它解决什么问题？\n\nSolidity 和 Vyper 默认会在合约字节码末尾附加元数据：编译器版本，以及（对 Solidity 而言）元数据 JSON 的 IPFS 或 Swarm 哈希，经 CBOR 编码，后面再跟 2 字节的长度。区块浏览器等源码验证工具在把链上代码与重新编译的结果比较之前，必须先把它剥离。由于传统字节码没有结构，它们只能依靠启发式方法，而带有嵌套字节码的工厂合约会让情况更糟。\n\nEVM 对象格式（[EIP-3540](/eip-3540/)）增加了结构：独立的代码部分和数据部分。但由于没有专门存放元数据的位置，编译器只能把它放进数据部分，这会带来以下问题：\n\n1. 仍然很难与真正的数据区分开；\n2. 元数据大小的变化会移动数据偏移量（例如 [EIP-7480](/eip-7480/) 中 `DATALOADN` 的立即数），导致逻辑相同的两个合约生成不同的代码；\n3. 理论上代码可以读取它。\n\n## 它如何运作\n\nEIP-7834 在 EOF 容器主体中增加一个**可选的 `metadata_section`**，放在所有容器部分之后、数据部分**之前**，并在头部增加对应的条目：\n\n| 头部字段 | 大小 | 取值 |\n| --- | --- | --- |\n| `kind_metadata` | 1 字节 | `0x05` |\n| `metadata_size` | 2 字节 | `0x0001`–`0xFFFF`，大端序 |\n\n头部条目位于 `kind_data`（`0xff`）之前。代码无法访问该部分，本 EIP 也不定义它的编码；预计编译器会继续使用 CBOR。\n\n为什么放在数据部分之前？因为数据在部署期间可能增长（EOF 允许向数据追加内容），否则会导致元数据被挤动。为什么用 `0x05` 而不是下一个空闲的 kind？为了便于现有 EOF 工具采用。\n\n## 示例代码\n\n带有新增可选字段的容器语法：\n\n```text\nheader :=\n    magic, version,\n    kind_type, type_size,\n    kind_code, num_code_sections, code_size+,\n    [kind_container, num_container_sections, container_size+,]\n    [kind_metadata, metadata_size,]          ; NEW, 0x05\n    kind_data, data_size,\n    terminator\nbody := types_section, code_section+, container_section*,\n        [metadata_section],                  ; NEW\n        data_section\n```\n\n这样验证方就可以比较除元数据字节以外的所有内容（TypeScript 草图）：\n\n```ts\nfunction stripMetadata(container: EofContainer): Uint8Array {\n  // With a dedicated section, no heuristics are needed:\n  return container.serialize({ omitSections: [\"metadata\"] });\n}\nconst match = equal(stripMetadata(onchain), stripMetadata(compiled));\n```\n\n这里的 `EofContainer` 是一个假设的解析器类型，并非某个具体的库。\n\n## 需要注意\n\n- **状态：Review。** 它扩展的是 EOF，而 EOF 本身处于 **Stagnant** 状态：EOF（[EIP-3540](/eip-3540/)，元 EIP 为 [EIP-7692](/eip-7692/)）已从 Fusaka 升级中移除，目前在主网上未激活。只有 EOF 被重新启动时，这个 EIP 才有意义。\n- 不存在向后兼容性问题，因为 EOF 从未部署过。\n- 传统（非 EOF）合约不受影响；对于它们，验证方仍然需要如今的启发式方法。\n"}}}
