---
eip: 7949
label: EIP-7949
title: Genesis File Format
status: Draft
type: Informational
created: 2025-05-19
official: https://eips.ethereum.org/EIPS/eip-7949
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7949.md
canonical: https://eips.huatuo.xyz/zh/eip-7949/
lang: zh
tldr: 把事实标准的 Geth 风格 genesis.json 格式写成 JSON Schema，使每个客户端和工具都能从同一个文件启动同一个网络，无需猜测。
tags: [genesis, configuration, client, json-schema, informational]
---

# EIP-7949: Genesis File Format

> Schema for `genesis.json` files

**TL;DR:** 把事实标准的 Geth 风格 genesis.json 格式写成 JSON Schema，使每个客户端和工具都能从同一个文件启动同一个网络，无需猜测。

## 它解决什么问题？

每个以太坊网络都从一个创世文件开始，它设定了链 ID、分叉计划以及初始余额和合约。实际上，客户端都趋同于 Geth 使用的布局，但没有任何官方文档描述它。规范指出，这给在测试网或开发网上同时运行多个客户端的人带来了不兼容、bug 和额外的工作。

较新的提案也在不断向创世配置添加字段，例如 blob 调度（[EIP-7840](/eip-7840/)）和 Blob Parameter Only 分叉（[EIP-7892](/eip-7892/)）。EIP-7949 定义了这些变更所挂载的根结构，以及工具可用来校验的 JSON Schema。

## 它如何运作

**顶层：** `config`、`alloc`、`nonce`、`timestamp`、`extraData`、`gasLimit`、`difficulty`、`mixhash`、`coinbase`。数值型区块头的值是十六进制字符串。schema 要求必须有 `alloc`、`gasLimit` 和 `difficulty`。

**`config`**（除特别说明外为十进制整数）：

- `chainId`。
- 分叉激活键：按区块号激活的分叉用 `<fork>Block`（`londonBlock` 等），按时间戳激活的分叉用 `<fork>Time`（`shanghaiTime`、`cancunTime`、`pragueTime`、`osakaTime`）。
- `terminalTotalDifficulty`（十六进制字符串）和 `depositContractAddress`。
- `blobSchedule`：每个分叉的 `target`、`max` 和 `baseFeeUpdateFraction`。
- 允许未知键，因此客户端特有的扩展仍可通过校验。

**`alloc`** 把地址映射到 `balance`（wei，十六进制）、`nonce`、`code` 和 `storage`（32 字节十六进制的键和值）。

## 示例代码

遵循该 schema 的最小开发网创世文件（数值仅作示意）：

```json
{
  "config": {
    "chainId": 1337,
    "londonBlock": 0,
    "terminalTotalDifficulty": "0x0",
    "shanghaiTime": 0,
    "cancunTime": 0,
    "pragueTime": 0,
    "blobSchedule": {
      "cancun": { "target": 3, "max": 6, "baseFeeUpdateFraction": 3338477 },
      "prague": { "target": 6, "max": 9, "baseFeeUpdateFraction": 5007716 }
    }
  },
  "nonce": "0x0",
  "timestamp": "0x0",
  "extraData": "0x",
  "gasLimit": "0x1c9c380",
  "difficulty": "0x0",
  "alloc": {
    "0x1111111111111111111111111111111111111111": { "balance": "0xde0b6b3a7640000" }
  }
}
```

使用 EIP 中的 schema 校验（本地保存为 `genesis.schema.json`）：

```bash
npx ajv-cli validate -s genesis.schema.json -d genesis.json
```

## 需要注意

- 状态：**Draft**（Informational）。它记录的是现有实践，不改变共识。
- 注意类型：顶层区块头字段是十六进制字符串，而 `config` 内的 `chainId`、分叉激活值和 `blobSchedule` 数字则是十进制整数。
- 真实的开发网通常需要比这个最小文件更多的内容（`alloc` 中的系统合约、存款合约等），具体取决于创世时激活了哪些分叉。
- 运行中节点的实际生效配置可以用 `eth_config`（[EIP-7910](/eip-7910/)）检查。


---

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