{"eip":8317,"title":"Contract Storage Layout Descriptor Format","description":"Defines a language-neutral, extensible JSON format for describing the storage layout of EVM contracts","authors":["Alex Forshtat (@forshtat)"],"status":"Draft","type":"Standards Track","category":"Interface","created":"2026-06-25","requires":[7201,7730,8042],"discussionsTo":"https://ethereum-magicians.org/t/erc-8317-contract-storage-layout-descriptor-format/28864","repo":"EIPs","label":"EIP-8317","officialUrl":"https://eips.ethereum.org/EIPS/eip-8317","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8317.md","url":"https://eips.huatuo.xyz/eip-8317/","tldr":{"en":"A language-neutral JSON format describing where each contract variable lives in storage, including namespaced and diamond layouts, so wallets and explorers can turn raw slot changes into 'Balance of Alice went from 10 to 5'.","ja":"コントラクトの各変数がストレージのどこにあるかを記述する、言語非依存の JSON 形式。名前空間付きや diamond のレイアウトも含み、ウォレットやエクスプローラーが生のスロット変更を「Alice の残高が 10 から 5 になった」に変換できるようにする。","ko":"컨트랙트의 각 변수가 스토리지 어디에 있는지 기술하는, 언어 중립적인 JSON 형식. 네임스페이스와 diamond 레이아웃도 포함하며, 지갑과 익스플로러가 원시 슬롯 변경을 'Alice의 잔액이 10에서 5로 바뀜'으로 바꿔 보여 줄 수 있게 한다.","zh":"一种与语言无关的 JSON 格式，用来描述合约每个变量在存储中的位置，包括带命名空间和 diamond 的布局，让钱包和浏览器能把原始的存储槽变化翻译成“Alice 的余额从 10 变成了 5”。"},"tags":["storage","tooling","wallets","clear-signing","json"],"explainers":{"en":{"lang":"en","tldr":"A language-neutral JSON format describing where each contract variable lives in storage, including namespaced and diamond layouts, so wallets and explorers can turn raw slot changes into 'Balance of Alice went from 10 to 5'.","tags":["storage","tooling","wallets","clear-signing","json"],"related":[7201,8042,7730,7906,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8317/","markdown":"## What problem does it solve?\n\nA transaction simulation tells you which raw storage slots changed: `(contract, slot, old, new)`. To show a user something meaningful, a wallet must know which variable each slot belongs to. Today tools lean on Solidity's `storageLayout` compiler output, which has problems:\n\n- It is Solidity-specific (type IDs like `t_uint256`), and other languages do not emit it.\n- Solidity documents it as experimental and subject to change.\n- It cannot describe layouts the compiler does not know about, such as [ERC-7201](/eip-7201/) namespaced storage or [ERC-8042](/eip-8042/) diamond storage, nor hand-written assembly contracts.\n\nThis EIP defines one stable schema for storage layouts so wallets, explorers, debuggers and security tools can share descriptors, for example to explain the effect of a transaction or of [EIP-7906](/eip-7906/) transaction assertions.\n\n## How it works\n\nA layout file is JSON with three required parts:\n\n- `compiler`: `language` (`\"Solidity\"`, `\"Vyper\"` or `\"manual\"` for Huff/Yul/assembly) and optional version and settings.\n- `storage`: ordered entries, each with `label`, `slot` (decimal string), byte `offset`, `type`, and optionally `path`, `source` (`\"compiler\"` or `\"manual\"`), `baseSlotDerivation` and `display`.\n- `types`: type definitions with an `encoding` (`inplace`, `inplace_struct`, `mapping`, `dynamic_array`, `bytes`), a source-level `label` and `numberOfBytes`.\n\nKey ideas:\n\n- **Verifiable base slots.** `baseSlotDerivation` names the scheme (`erc7201`, `erc8042` or `custom`) and the namespace ID, so a consumer can recompute the slot instead of trusting it.\n- **Normative derivation formulas** per language and encoding, for example Solidity mappings at `keccak256(abi.encode(key, baseSlot))`, and Vyper's differences (inline `bytes`, reversed key order before Vyper 0.3.0).\n- **Packed variables** are extracted using `offset` and `numberOfBytes`.\n- **Display annotations** reuse the [ERC-7730](/eip-7730/) vocabulary: labels with `{key[N]}`/`{index[N]}` placeholders, value formatters such as `tokenAmount`, and templates with JSON Logic conditions.\n- Transient storage is out of scope since it does not outlive the transaction.\n\n## Sample code\n\nA minimal descriptor for an ERC-20 balance mapping:\n\n```json\n{\n  \"compiler\": { \"language\": \"Solidity\", \"version\": \"0.8.24\" },\n  \"storage\": [\n    {\n      \"label\": \"_balances\",\n      \"slot\": \"0\",\n      \"offset\": 0,\n      \"type\": \"t_mapping(t_address,t_uint256)\",\n      \"display\": {\n        \"label\": \"Balance of {key[0]}\",\n        \"keyFormats\": [{ \"format\": \"addressName\" }],\n        \"template\": \"{label} changed from {oldValue} to {newValue}\"\n      }\n    }\n  ],\n  \"types\": {\n    \"t_address\": { \"encoding\": \"inplace\", \"label\": \"address\", \"numberOfBytes\": \"20\" },\n    \"t_uint256\": { \"encoding\": \"inplace\", \"label\": \"uint256\", \"numberOfBytes\": \"32\" },\n    \"t_mapping(t_address,t_uint256)\": {\n      \"encoding\": \"mapping\", \"label\": \"mapping(address =\u003e uint256)\",\n      \"numberOfBytes\": \"32\", \"key\": \"t_address\", \"value\": \"t_uint256\"\n    }\n  }\n}\n```\n\n## Things to know\n\n- Status is **Draft**; the schema and supported languages may change. New languages must be added by updating this ERC.\n- The file format defines no trust model. A malicious descriptor could mislabel a real storage change, so standards that use it (such as ERC-7730) must establish authenticity before wallets rely on it.\n- `display.description` is informative only and must not drive security decisions.\n- Descriptors can mix compiler-emitted and hand-authored entries, which matters for proxies, diamonds and EIP-7702 delegates.\n"},"ja":{"lang":"ja","tldr":"コントラクトの各変数がストレージのどこにあるかを記述する、言語非依存の JSON 形式。名前空間付きや diamond のレイアウトも含み、ウォレットやエクスプローラーが生のスロット変更を「Alice の残高が 10 から 5 になった」に変換できるようにする。","tags":["storage","tooling","wallets","clear-signing","json"],"related":[7201,8042,7730,7906,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8317/","markdown":"## 何を解決するのか\n\nトランザクションのシミュレーションは、どの生のストレージスロットが変わったかを `(contract, slot, old, new)` の形で教えてくれます。ユーザーに意味のあるものを見せるには、ウォレットが各スロットがどの変数に属するかを知っていなければなりません。現状、ツールは Solidity コンパイラの `storageLayout` 出力に頼っていますが、これには問題があります。\n\n- Solidity に固有で（`t_uint256` のような型 ID）、他の言語は出力しません。\n- Solidity はこれを実験的であり、変更される可能性があるものとして文書化しています。\n- コンパイラが知らないレイアウト、たとえば [ERC-7201](/eip-7201/) の名前空間付きストレージや [ERC-8042](/eip-8042/) の diamond ストレージ、あるいは手書きアセンブリのコントラクトを記述できません。\n\nこの EIP は、ストレージレイアウトのための安定したスキーマを 1 つ定義し、ウォレット、エクスプローラー、デバッガー、セキュリティツールが記述子を共有できるようにします。たとえば、トランザクションや [EIP-7906](/eip-7906/) のトランザクションアサーションの効果を説明するために使えます。\n\n## 仕組み\n\nレイアウトファイルは、3 つの必須部分を持つ JSON です。\n\n- `compiler`: `language`（`\"Solidity\"`、`\"Vyper\"`、または Huff/Yul/アセンブリ用の `\"manual\"`）と、任意のバージョンおよび設定。\n- `storage`: 順序付きのエントリー。各エントリーは `label`、`slot`（10 進文字列）、バイトの `offset`、`type` を持ち、任意で `path`、`source`（`\"compiler\"` または `\"manual\"`）、`baseSlotDerivation`、`display` を持ちます。\n- `types`: `encoding`（`inplace`、`inplace_struct`、`mapping`、`dynamic_array`、`bytes`）、ソースレベルの `label`、`numberOfBytes` を持つ型定義。\n\n主なアイデア:\n\n- **検証可能なベーススロット。** `baseSlotDerivation` は方式（`erc7201`、`erc8042`、または `custom`）と名前空間 ID を示すので、利用側はスロットを信用せずに再計算できます。\n- 言語とエンコーディングごとの**規範的な導出式**。たとえば、Solidity のマッピングは `keccak256(abi.encode(key, baseSlot))` に置かれ、Vyper には違い（インラインの `bytes`、Vyper 0.3.0 より前はキーの順序が逆）があります。\n- **パックされた変数**は、`offset` と `numberOfBytes` を使って取り出します。\n- **表示用アノテーション**は [ERC-7730](/eip-7730/) の語彙を再利用します。`{key[N]}`/`{index[N]}` のプレースホルダー付きラベル、`tokenAmount` などの値フォーマッター、JSON Logic の条件付きテンプレートです。\n- transient storage は、トランザクションより長く残らないため、対象外です。\n\n## サンプルコード\n\nERC-20 の残高マッピングの最小限の記述子:\n\n```json\n{\n  \"compiler\": { \"language\": \"Solidity\", \"version\": \"0.8.24\" },\n  \"storage\": [\n    {\n      \"label\": \"_balances\",\n      \"slot\": \"0\",\n      \"offset\": 0,\n      \"type\": \"t_mapping(t_address,t_uint256)\",\n      \"display\": {\n        \"label\": \"Balance of {key[0]}\",\n        \"keyFormats\": [{ \"format\": \"addressName\" }],\n        \"template\": \"{label} changed from {oldValue} to {newValue}\"\n      }\n    }\n  ],\n  \"types\": {\n    \"t_address\": { \"encoding\": \"inplace\", \"label\": \"address\", \"numberOfBytes\": \"20\" },\n    \"t_uint256\": { \"encoding\": \"inplace\", \"label\": \"uint256\", \"numberOfBytes\": \"32\" },\n    \"t_mapping(t_address,t_uint256)\": {\n      \"encoding\": \"mapping\", \"label\": \"mapping(address =\u003e uint256)\",\n      \"numberOfBytes\": \"32\", \"key\": \"t_address\", \"value\": \"t_uint256\"\n    }\n  }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。スキーマと対応言語は変わる可能性があります。新しい言語は、この ERC を更新して追加しなければなりません。\n- このファイル形式は、信頼モデルを定義しません。悪意のある記述子は、実際のストレージ変更に誤ったラベルを付けるかもしれません。そのため、これを使う標準（ERC-7730 など）は、ウォレットが頼る前に真正性を確立しなければなりません。\n- `display.description` は情報提供のみを目的としており、セキュリティ上の判断の根拠にしてはなりません。\n- 記述子には、コンパイラが出力したエントリーと手書きのエントリーを混在させられます。これは、プロキシ、diamond、EIP-7702 のデリゲートで重要になります。\n"},"ko":{"lang":"ko","tldr":"컨트랙트의 각 변수가 스토리지 어디에 있는지 기술하는, 언어 중립적인 JSON 형식. 네임스페이스와 diamond 레이아웃도 포함하며, 지갑과 익스플로러가 원시 슬롯 변경을 'Alice의 잔액이 10에서 5로 바뀜'으로 바꿔 보여 줄 수 있게 한다.","tags":["storage","tooling","wallets","clear-signing","json"],"related":[7201,8042,7730,7906,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8317/","markdown":"## 어떤 문제를 해결하나요?\n\n트랜잭션 시뮬레이션은 어떤 원시 스토리지 슬롯이 바뀌었는지를 `(contract, slot, old, new)` 형태로 알려 줍니다. 사용자에게 의미 있는 내용을 보여 주려면 지갑이 각 슬롯이 어느 변수에 속하는지 알아야 합니다. 지금은 도구들이 Solidity 컴파일러의 `storageLayout` 출력에 의존하는데, 여기에는 문제가 있습니다.\n\n- Solidity 전용이며(`t_uint256` 같은 타입 ID) 다른 언어는 이를 내보내지 않습니다.\n- Solidity는 이를 실험적이며 바뀔 수 있는 것으로 문서화합니다.\n- 컴파일러가 모르는 레이아웃, 예를 들어 [ERC-7201](/eip-7201/)의 네임스페이스 스토리지나 [ERC-8042](/eip-8042/)의 diamond 스토리지, 또는 손으로 쓴 어셈블리 컨트랙트는 기술할 수 없습니다.\n\n이 EIP는 스토리지 레이아웃을 위한 안정적인 스키마를 하나 정의해, 지갑, 익스플로러, 디버거, 보안 도구가 기술자(descriptor)를 공유할 수 있게 합니다. 예를 들어 트랜잭션이나 [EIP-7906](/eip-7906/)의 트랜잭션 어서션의 효과를 설명하는 데 쓸 수 있습니다.\n\n## 어떻게 동작하나요?\n\n레이아웃 파일은 세 가지 필수 부분을 가진 JSON입니다.\n\n- `compiler`: `language`(`\"Solidity\"`, `\"Vyper\"`, 또는 Huff/Yul/어셈블리용 `\"manual\"`)와 선택적인 버전 및 설정.\n- `storage`: 순서가 있는 항목들. 각 항목은 `label`, `slot`(십진 문자열), 바이트 `offset`, `type`을 가지며, 선택적으로 `path`, `source`(`\"compiler\"` 또는 `\"manual\"`), `baseSlotDerivation`, `display`를 가집니다.\n- `types`: `encoding`(`inplace`, `inplace_struct`, `mapping`, `dynamic_array`, `bytes`), 소스 수준의 `label`, `numberOfBytes`를 가진 타입 정의.\n\n핵심 아이디어:\n\n- **검증 가능한 기본 슬롯.** `baseSlotDerivation`이 방식(`erc7201`, `erc8042`, 또는 `custom`)과 네임스페이스 ID를 명시하므로, 사용하는 쪽은 슬롯을 그대로 믿는 대신 다시 계산할 수 있습니다.\n- 언어와 인코딩별 **규범적 유도 공식**. 예를 들어 Solidity 매핑은 `keccak256(abi.encode(key, baseSlot))`에 위치하며, Vyper는 차이가 있습니다(인라인 `bytes`, Vyper 0.3.0 이전에는 키 순서가 반대).\n- **패킹된 변수**는 `offset`과 `numberOfBytes`로 추출합니다.\n- **표시 주석**은 [ERC-7730](/eip-7730/)의 어휘를 재사용합니다. `{key[N]}`/`{index[N]}` 플레이스홀더가 있는 레이블, `tokenAmount` 같은 값 포매터, JSON Logic 조건이 있는 템플릿입니다.\n- transient storage는 트랜잭션보다 오래 살아남지 않으므로 범위 밖입니다.\n\n## 샘플 코드\n\nERC-20 잔액 매핑을 위한 최소한의 기술자:\n\n```json\n{\n  \"compiler\": { \"language\": \"Solidity\", \"version\": \"0.8.24\" },\n  \"storage\": [\n    {\n      \"label\": \"_balances\",\n      \"slot\": \"0\",\n      \"offset\": 0,\n      \"type\": \"t_mapping(t_address,t_uint256)\",\n      \"display\": {\n        \"label\": \"Balance of {key[0]}\",\n        \"keyFormats\": [{ \"format\": \"addressName\" }],\n        \"template\": \"{label} changed from {oldValue} to {newValue}\"\n      }\n    }\n  ],\n  \"types\": {\n    \"t_address\": { \"encoding\": \"inplace\", \"label\": \"address\", \"numberOfBytes\": \"20\" },\n    \"t_uint256\": { \"encoding\": \"inplace\", \"label\": \"uint256\", \"numberOfBytes\": \"32\" },\n    \"t_mapping(t_address,t_uint256)\": {\n      \"encoding\": \"mapping\", \"label\": \"mapping(address =\u003e uint256)\",\n      \"numberOfBytes\": \"32\", \"key\": \"t_address\", \"value\": \"t_uint256\"\n    }\n  }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 스키마와 지원 언어는 바뀔 수 있습니다. 새 언어는 이 ERC를 갱신해서 추가해야 합니다.\n- 이 파일 형식은 신뢰 모델을 정의하지 않습니다. 악의적인 기술자는 실제 스토리지 변경에 잘못된 레이블을 붙일 수 있으므로, 이를 사용하는 표준(예: ERC-7730)은 지갑이 이에 의존하기 전에 진본성을 확립해야 합니다.\n- `display.description`은 참고용일 뿐이며 보안 판단의 근거로 삼아서는 안 됩니다.\n- 기술자에는 컴파일러가 내보낸 항목과 직접 작성한 항목이 섞일 수 있으며, 이는 프록시, diamond, EIP-7702 delegate에서 중요합니다.\n"},"zh":{"lang":"zh","tldr":"一种与语言无关的 JSON 格式，用来描述合约每个变量在存储中的位置，包括带命名空间和 diamond 的布局，让钱包和浏览器能把原始的存储槽变化翻译成“Alice 的余额从 10 变成了 5”。","tags":["storage","tooling","wallets","clear-signing","json"],"related":[7201,8042,7730,7906,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8317/","markdown":"## 它解决什么问题？\n\n交易模拟会告诉你哪些原始存储槽发生了变化：`(contract, slot, old, new)`。要向用户展示有意义的内容，钱包必须知道每个存储槽属于哪个变量。目前工具依赖 Solidity 编译器输出的 `storageLayout`，它存在一些问题：\n\n- 它是 Solidity 专属的（类型 ID 如 `t_uint256`），其他语言不会生成。\n- Solidity 把它标注为实验性的，可能会更改。\n- 它无法描述编译器不了解的布局，例如 [ERC-7201](/eip-7201/) 的命名空间存储或 [ERC-8042](/eip-8042/) 的 diamond 存储，也无法描述手写汇编的合约。\n\n这个 EIP 为存储布局定义了一个稳定的模式（schema），让钱包、浏览器、调试器和安全工具可以共享描述文件，例如用来解释一笔交易或 [EIP-7906](/eip-7906/) 交易断言的效果。\n\n## 它如何运作\n\n布局文件是一个 JSON，包含三个必需部分：\n\n- `compiler`：`language`（`\"Solidity\"`、`\"Vyper\"`，或用于 Huff/Yul/汇编的 `\"manual\"`），以及可选的版本和设置。\n- `storage`：有序的条目，每个条目包含 `label`、`slot`（十进制字符串）、字节 `offset`、`type`，以及可选的 `path`、`source`（`\"compiler\"` 或 `\"manual\"`）、`baseSlotDerivation` 和 `display`。\n- `types`：类型定义，包含 `encoding`（`inplace`、`inplace_struct`、`mapping`、`dynamic_array`、`bytes`）、源码级别的 `label` 和 `numberOfBytes`。\n\n关键思路：\n\n- **可验证的基础存储槽。** `baseSlotDerivation` 指明方案（`erc7201`、`erc8042` 或 `custom`）和命名空间 ID，所以使用方可以重新计算存储槽，而不必盲目相信它。\n- 按语言和编码给出的**规范性推导公式**，例如 Solidity 的 mapping 位于 `keccak256(abi.encode(key, baseSlot))`，以及 Vyper 的差异（内联 `bytes`，Vyper 0.3.0 之前键的顺序相反）。\n- **打包变量**通过 `offset` 和 `numberOfBytes` 提取。\n- **显示注解**复用 [ERC-7730](/eip-7730/) 的词汇：带有 `{key[N]}`/`{index[N]}` 占位符的标签、`tokenAmount` 之类的值格式化器，以及带 JSON Logic 条件的模板。\n- 瞬态存储不在范围内，因为它的寿命不超过该笔交易。\n\n## 示例代码\n\n一个 ERC-20 余额 mapping 的最小描述文件：\n\n```json\n{\n  \"compiler\": { \"language\": \"Solidity\", \"version\": \"0.8.24\" },\n  \"storage\": [\n    {\n      \"label\": \"_balances\",\n      \"slot\": \"0\",\n      \"offset\": 0,\n      \"type\": \"t_mapping(t_address,t_uint256)\",\n      \"display\": {\n        \"label\": \"Balance of {key[0]}\",\n        \"keyFormats\": [{ \"format\": \"addressName\" }],\n        \"template\": \"{label} changed from {oldValue} to {newValue}\"\n      }\n    }\n  ],\n  \"types\": {\n    \"t_address\": { \"encoding\": \"inplace\", \"label\": \"address\", \"numberOfBytes\": \"20\" },\n    \"t_uint256\": { \"encoding\": \"inplace\", \"label\": \"uint256\", \"numberOfBytes\": \"32\" },\n    \"t_mapping(t_address,t_uint256)\": {\n      \"encoding\": \"mapping\", \"label\": \"mapping(address =\u003e uint256)\",\n      \"numberOfBytes\": \"32\", \"key\": \"t_address\", \"value\": \"t_uint256\"\n    }\n  }\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**；模式和支持的语言可能会变化。新增语言必须通过更新这个 ERC 来加入。\n- 该文件格式没有定义信任模型。恶意的描述文件可能会错误标注一次真实的存储变化，因此使用它的标准（如 ERC-7730）必须在钱包依赖它之前确立其真实性。\n- `display.description` 仅供参考，不得用来驱动安全决策。\n- 描述文件可以混合编译器生成的条目和手工编写的条目，这对代理、diamond 和 EIP-7702 delegate 很重要。\n"}}}
