# @ethernauta/chain 中文文档

规范地址：https://npmcn.com/package/%40ethernauta/chain/

版本：0\.0\.48
npm 元数据更新时间：2026-06-04T13:53:19.791Z
中文译文更新时间：2026-11-13T23:41:27.288Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40ethernauta/chain
原文对照：https://npmcn.com/package/%40ethernauta/chain/?lang=original
项目主页：https://ethernauta-docs.pages.dev/
源码仓库：https://github.com/niconiahi/ethernauta

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：7.8 MB，13189 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：valibot ^1\.1\.0
- 首次发布：2025-08-07T16:06:19.012Z
- 最新版本发布：2026-06-04T13:53:19.658Z
- 近 30 天下载量：8452（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：33（近 12 个月 7 个）

## 中文简介

500+ EIP-155 Ethernauta的链定义,由链 id索引.

## 安装

```sh
npm install @ethernauta/chain
```

也可以使用：`pnpm add @ethernauta/chain`、`yarn add @ethernauta/chain`、`bun add @ethernauta/chain`

## README

[![bundlejs](https://deno.bundlejs.com/badge?q=@ethernauta/chain&treeshake=%5B*%5D)](https://deno.bundlejs.com/?q=@ethernauta/chain&treeshake=%5B*%5D)

## 哲学

本单元是对公共链条目录的不表示:

-   [铁链](https://github.com/ethereum-lists/chains/tree/master/_data/chains)
-   [链式方案](https://github.com/ethereum-lists/chains/blob/master/tools/schema/ChainSchema.json)

上游列表中的每个链都导出为冠名 `eip155_<chainId>` (每个链条一个文件). 与相机对等 `encode_chain_id` 从 `@ethernauta/transport` 生成一个 [CAIP-2 联合国](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) 每个以太上纳乌塔溶液厂都接受.

一个小的衍生工具—— `runIndexer` ——从上游仓库刷新目录.

## 模块

-   [阿比比语](https://github.com/niconiahi/ethernauta/tree/main/packages/abi) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/abi)\[ . \]
-   [链式](https://github.com/niconiahi/ethernauta/tree/main/packages/chain) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/chain)\[ . \]
-   [语气](https://github.com/niconiahi/ethernauta/tree/main/packages/cli) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/cli)\[ . \]
-   [核心项目](https://github.com/niconiahi/ethernauta/tree/main/packages/core) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/core)\[ . \]
-   [密码](https://github.com/niconiahi/ethernauta/tree/main/packages/crypto) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/crypto)\[ . \]
-   [叶](https://github.com/niconiahi/ethernauta/tree/main/packages/eip) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/eip)\[ . \]
-   [单位](https://github.com/niconiahi/ethernauta/tree/main/packages/ens) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/ens)\[ . \]
-   [埃尔克](https://github.com/niconiahi/ethernauta/tree/main/packages/erc) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/erc)\[ . \]
-   [特尔](https://github.com/niconiahi/ethernauta/tree/main/packages/eth) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/eth)\[ . \]
-   [反应](https://github.com/niconiahi/ethernauta/tree/main/packages/react) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/react)\[ . \]
-   [交易](https://github.com/niconiahi/ethernauta/tree/main/packages/transaction) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/transaction)\[ . \]
-   [运输](https://github.com/niconiahi/ethernauta/tree/main/packages/transport) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/transport)\[ . \]
-   [倾斜](https://github.com/niconiahi/ethernauta/tree/main/packages/utils) \[[国家预防机制](https://www.npmjs.com/package/@ethernauta/utils)\[ . \]
-   [钱包](https://github.com/niconiahi/ethernauta/tree/main/packages/wallet)

## API 密码

### 链轴-每条EIP-155链1个

```ts
import {
  eip155_1,           // Ethereum Mainnet
  eip155_10,          // OP Mainnet
  eip155_8453,        // Base
  eip155_42161,       // Arbitrum One
  eip155_11155111,    // Sepolia
  // …500+ exports
} from "@ethernauta/chain"

// Each const exposes the upstream `ChainSchema` shape:
//   { name, shortName, chainId, networkId, nativeCurrency,
//     rpc, explorers, … }
```

### 用 CAIP-2 代号对一链

```ts
import { eip155_11155111 } from "@ethernauta/chain"
import { decode_chain_id, encode_chain_id } from "@ethernauta/transport"

const chain_id = encode_chain_id({
  namespace: "eip155",
  reference: eip155_11155111.chainId,
})
console.log(chain_id) // "eip155:11155111"

const { namespace, reference } = decode_chain_id(chain_id)
console.log(namespace) // "eip155"
console.log(reference) // "11155111"
```

### 示马斯

```ts
import {
  type Chain,
  ChainSchema,
  type Feature,
  type NativeCurrency,
  type Explorer,
  type Bridge,
  type Parent,
  type EnsRegistry,
  type ShortName,
  ShortNameSchema,
  type RedFlagSchema,
} from "@ethernauta/chain"

// `ChainSchema` matches the upstream JSON schema and is what
// every `eip155_*` export validates against at build time.
```

### 刷新目录

```bash
pnpm --filter @ethernauta/chain indexer
```

这个 `indexer` 脚本从 [电子列表/链](https://github.com/ethereum-lists/chains),每个对照 `ChainSchema`,然后每条链条写一个 TS 文件 `src/chain/eip155/`。 。 。 .

## 常见问题

### @ethernauta/chain 是什么？

500\+ EIP-155 Ethernauta的链定义,由链 id索引\.

### 如何安装 @ethernauta/chain？

在项目目录运行 npm install @ethernauta/chain，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：valibot（^1\.1\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @ethernauta/chain 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @ethernauta/chain 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @ethernauta/chain 可以商用吗？

@ethernauta/chain 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @ethernauta/chain 的下载量有多少？

根据 npm 官方下载统计，@ethernauta/chain 在 2026/10/14 – 2026/11/12 这 30 天内被下载 8,452 次，日均约 282 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @ethernauta/chain 还在维护吗？

最新版本 0\.0\.48 发布于 2026/06/04（5 个月前）；至今共发布 33 个版本，其中过去 12 个月发布了 7 个；首次发布于 2025/08/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

