# @depay/web3-blockchains 中文文档

规范地址：https://npmcn.com/package/%40depay/web3-blockchains/

版本：9\.8\.13
npm 元数据更新时间：2026-03-29T17:11:11.112Z
中文译文更新时间：2026-11-11T22:56:06.361Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40depay/web3-blockchains
原文对照：https://npmcn.com/package/%40depay/web3-blockchains/?lang=original
项目主页：https://depay.com/
源码仓库：https://github.com/DePayFi/web3-blockchains

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

- 包体积（解压后）：170 kB，5 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- Node.js 要求：\>=18
- 运行依赖：0 个
- 首次发布：2021-11-26T16:42:10.881Z
- 最新版本发布：2026-03-29T17:11:10.807Z
- 近 30 天下载量：99292（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：112（近 12 个月 3 个）

## 中文简介

JavaScript 库,包含Web3块链的汇总信息和抽象.

## 安装

```sh
npm install @depay/web3-blockchains
```

也可以使用：`pnpm add @depay/web3-blockchains`、`yarn add @depay/web3-blockchains`、`bun add @depay/web3-blockchains`

## README

## 快速启动

```
yarn add @depay/web3-blockchains
```

或者说

```
npm install --save @depay/web3-blockchains
```

```javascript
import Blockchains from '@depay/web3-blockchains'

Blockchains.all
// [
//   { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' },
//   { name: 'bsc', id: '0x38', label: 'Binance Smart Chain', logo: '...' },
//   ...
// ]

Blockchains.findByName('ethereum')
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }

Blockchains.findById('0x1')
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }

Blockchains.findByNetworkId(1)
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }
```

或者说

```javascript
import { all, findByName, findById, findByNetworkId } from '@depay/web3-blockchains'

all
// [
//   { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' },
//   { name: 'bsc', id: '0x38', label: 'Binance Smart Chain', logo: '...' },
//   ...
// ]

findByName('ethereum')
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }

findById('0x1')
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }

findByNetworkId(1)
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }
```

或者说

```javascript
import Blockchains from '@depay/web3-blockchains'

Blockchains['ethereums']
// { name: 'ethereum', id: '0x1', label: 'Ethereum', logo: '...' }
```

## 支助

此库支持以下块链 :

-   [以利亚](https://ethereum.org/)
-   [BNB 智能链](https://www.binance.org/smartChain)
-   [多边形](https://polygon.technology/)
-   [索拉纳](https://solana.com/)
-   [方图](https://fantom.foundation/)
-   [坐标](https://arbitrum.io/)
-   [雪崩](https://www.avax.network/)
-   [肠道](https://gnosis.io/)
-   [乐观主义](https://www.optimism.io/)
-   [基础](https://base.org/)
-   [世界链](https://worldcoin.org/world-chain)

## 数据结构

区块链数据按以下结构提供:

```javascript
{
  name: String, // e.g. ethereum, bsc ...
  id: String, // e.g. 0x1, 0x38, ...
  networkId: String, // 1, 56, ...
  namespace: String, // eip155, solana, ...
  label: String, // Ethereum, Binance Smart Chain ...
  fullName: String, // Ethereum Mainnet, Binance Smart Chain Mainnet ...
  logo: String, // base64 data or URL (logo for colored or dark background)
  logoBackgroundColor: String // hex color
  logoWhiteBackground: String // base64 data or url (logos for white background)
  currency: { Object
    name: String, // Ether, Binance Coin, ...
    symbol: String, // ETH, BNB, ...
    decimals: String, // 18
    address: String, // address or placeholder address
    logo: String, // base64 data or URL,
  },
  wrapped: { Object
    address: String, // address of the wrapped native scurrency
    decimals: Integer, // 18 
    logo: String, // base64 data or URL
  },
  stables: { Object
    usd: [ Array
      { Object
        address: String, // 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
        decimals: Integer, // 18
      }, ...
    ]
  },
  explorer: String (URL), // https://etherscan.io, https://bncscan.com, ...
  explorerUrlFor: Function ({ transaction || token }) returns String, // https://etherscan.io/tx/..., https://etherscan.io/token/...
  endpoints: [ Array
    String (URL), // https://rpc.ankr.com/eth
  ],
  sockets: [ // Array || undefined
    String (URL), // wss://mainnet-beta.solflare.network
  ],
  tokens: [ Array
    { Object
      address: String, // 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
      symbol: String, // USDC
      name: String, // USD Coin
      decimals: Integer, // 6
      logo: String(URL|Data URL), // https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x853d955aCEf822Db058eb8505911ED77F175b99e/logo.png 
      type: String, // 20
    }, 
  ],
  zero: String, // 0x0000000000000000000000000000000000000000
  maxInt: String, // 115792089237316195423570985008687907853269984665640564039457584007913129639935
  permit2: String, // 0x000000000022D473030F116dDEE9F6B43aC78BA3 (Permit2 contract address)
  blockTime: Integer, // in ms e.g. ethereum 12000 (12s)
}
```

### 探险家UrlFor

#### 交易

```javascript
blockchain.explorerUrlFor({ transaction: '0x51ae8875028b7ed004253f679076851abbd3a49e26faf8d7dac6bb283ca10536' })
// https://etherscan.io/tx/0x51ae8875028b7ed004253f679076851abbd3a49e26faf8d7dac6bb283ca10536
```

#### 脚本

```javascript
blockchain.explorerUrlFor({ token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb' })
// https://etherscan.io/token/0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb
```

#### 地址

```javascript
blockchain.explorerUrlFor({ address: '0x08B277154218CCF3380CAE48d630DA13462E3950' })
// https://etherscan.io/address/0x08B277154218CCF3380CAE48d630DA13462E3950
```

## 职能

### 全部: 对所有区块链检索所有信息

```javascript
import Blockchains from '@depay/web3-blockchains'

Blockchains.all
// [
//   { name: 'ethereum', id: '0x1', networkId: '1', label: 'Ethereum', logo: '...' },
//   { name: 'bsc', id: '0x38', networkId: '56', label: 'Binance Smart Chain', logo: '...' },
//   ...
// ]

```

### 找到ById: 通过块链 ID 获取块链

```javascript
import Blockchains from '@depay/web3-blockchains'

Blockchains.findById('0x1')
// { name: 'ethereum', id: '0x1', networkId: '1', label: 'Ethereum', logo: '...' }

Blockchains.findById('0x38')
// { name: 'bsc', id: '0x38', networkId: '56', label: 'Binance Smart Chain', logo: '...' }
```

### findByName:用块链名称获取块链

```javascript
import Blockchains from '@depay/web3-blockchains'

Blockchains.findByName('ethereum')
// { name: 'ethereum', id: '0x1', networkId: '1', label: 'Ethereum', logo: '...' }

Blockchains.findByName('bsc')
// { name: 'bsc', id: '0x38', networkId: '56', label: 'Binance Smart Chain', logo: '...' }
```

### 找到ByNetworkId:通过网络 id 获取块链

```javascript
import Blockchains from '@depay/web3-blockchains'

Blockchains.findByNetworkId(1)
// { name: 'ethereum', id: '0x1', networkId: '1', label: 'Ethereum', logo: '...' }

Blockchains.findByNetworkId('56')
// { name: 'bsc', id: '0x38', networkId: '56', label: 'Binance Smart Chain', logo: '...' }
```

## 发展

### 开始吧

```
yarn install
yarn dev
```

## 常见问题

### @depay/web3-blockchains 是什么？

JavaScript 库,包含Web3块链的汇总信息和抽象\.

### 如何安装 @depay/web3-blockchains？

在项目目录运行 npm install @depay/web3-blockchains，或使用 pnpm add / yarn add / bun add。

### @depay/web3-blockchains 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/depay\_\_web3-blockchains 是否存在。

### @depay/web3-blockchains 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @depay/web3-blockchains 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @depay/web3-blockchains 可以商用吗？

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

### @depay/web3-blockchains 的下载量有多少？

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

### @depay/web3-blockchains 还在维护吗？

最新版本 9\.8\.13 发布于 2026/03/30（7 个月前）；至今共发布 112 个版本，其中过去 12 个月发布了 3 个；首次发布于 2021/11/27。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

