---
eip: 7876
label: ERC-7876
title: Ethereum Network Configuration for DApps
status: Draft
type: Standards Track
category: ERC
created: 2025-01-03
requires: 55
official: https://eips.ethereum.org/EIPS/eip-7876
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7876.md
canonical: https://eips.huatuo.xyz/zh/eip-7876/
lang: zh
tldr: 一种标准 JSON 格式，用于描述 dapp 所支持的网络（RPC URL、原生货币、附带 ABI 链接的合约地址、区块浏览器以及测试网/L2 关系），使同一份网络配置可以在应用、平台和团队之间共享。
tags: [config, json, dapps, networks, tooling]
---

# ERC-7876: Ethereum Network Configuration for DApps

> EVM-compatible network configuration specification for DApps supporting any custom network features through extensions.

**TL;DR:** 一种标准 JSON 格式，用于描述 dapp 所支持的网络（RPC URL、原生货币、附带 ABI 链接的合约地址、区块浏览器以及测试网/L2 关系），使同一份网络配置可以在应用、平台和团队之间共享。

## 它解决什么问题？

支持众多 EVM 网络的 dapp 各自维护自己的网络列表：RPC 端点、链 ID、浏览器链接格式、已部署的合约地址。这些列表的结构各不相同，在 Web、iOS 和 Android 代码中重复存在，并在合约重新部署时逐渐失去同步。

ERC-7876 为这一切提出了一种统一的 JSON 格式。网络运营方可以发布配置，使 dapp 轻松支持它们；合约团队可以用一致的方式提供地址和 ABI；组织可以在各平台间共用一个文件。

## 它如何运作

顶层对象包含 `version`、`timestamp`（ISO 8601）、`summary`、`description`、可选的 `abiRoot`，以及以字符串形式的**链 ID**（如 `"1"`）为键的 `networks`。每个网络包含：

- `name`、`testnet` 和 `nativeCurrency`（`name`、`symbol`、`decimals`）。
- `rpcs`：带有 `url` 的命名条目。
- `relations`：`mainnetChainId`（用于测试网；主网上为 `null`）和 `parentChainId`（例如 L2 的 L1）。
- `explorers`：带有 `root` URL 以及使用 `:block`、`:address`、`:tx`、`:token` 的相对路径模板的命名条目；不可用的路径为 `null`。
- `contracts`：带有符合 [EIP-55](/eip-55/) 校验和的 `address`、`blockCreated` 和可选 `abiUrl`（相对于 `abiRoot` 或绝对路径）的命名条目。未部署在该网络上的合约明确为 `null`。ABI **不得**内联。

**扩展：**实现必须忽略未知属性（或在可行时使用它们）。扩展可以添加字段，但不得更改现有字段的类型；例如 `blockCreated` 必须保持为数字，而不是十六进制字符串。不鼓励使用联合类型。

该格式在可能的情况下遵循 [EIP-3085](/eip-3085/)（`wallet_addEthereumChain`），但在该结构会妨碍扩展的地方有所偏离。

## 示例代码

一个网络的最小配置（URL 和地址均为占位符）：

```json
{
  "version": "1.0.0",
  "timestamp": "2026-01-01T00:00:00Z",
  "summary": "Example dapp networks",
  "description": "Networks and contracts used by the example dapp",
  "abiRoot": "https://dapp.example.com/abi",
  "networks": {
    "11155111": {
      "name": "Sepolia",
      "testnet": true,
      "nativeCurrency": { "name": "Sepolia Ether", "symbol": "ETH", "decimals": 18 },
      "relations": { "mainnetChainId": 1, "parentChainId": null },
      "rpcs": { "main": { "url": "https://sepolia-rpc.example.com" } },
      "explorers": {
        "scan": { "root": "https://sepolia.explorer.example", "block": "/block/:block",
                  "address": "/address/:address", "tx": "/tx/:tx", "nft": null }
      },
      "contracts": {
        "Registry": { "address": "0x0000000000000000000000000000000000000001",
                      "blockCreated": 1, "abiUrl": "./Registry.json" },
        "Staking": null
      }
    }
  }
}
```

构建浏览器链接（TypeScript）：

```ts
const e = config.networks["11155111"].explorers.scan;
const url = e.root + e.tx!.replace(":tx", txHash);
```

## 需要注意

- 状态为 **Draft**。
- 文件中只应放置公开数据。绝不要包含私钥或助记词。规范允许为 RPC 提供 API 密钥扩展，但此类密钥**不得**放入公开分发的配置中。
- 在同一文件中，合约名称必须在所有网络上指代同一个合约；最好与 Solidity 合约名一致。
- 没有定义标准的合约名称；每个 dapp 自行选择。
- 它所对齐的 [EIP-3085](/eip-3085/) 本身已是 Stagnant 状态。


---

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