# @a16z/helios 中文文档

规范地址：https://npmcn.com/package/%40a16z/helios/

版本：0\.12\.0
npm 元数据更新时间：2026-10-05T23:36:06.960Z
中文译文更新时间：2026-11-06T18:12:29.459Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：12.4 MB，11 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：2 个
- 首次发布：2025-06-17T22:14:23.587Z
- 最新版本发布：2026-10-05T23:36:06.513Z
- 近 30 天下载量：2499（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：9（近 12 个月 3 个）

## 中文简介

一个快速、安全和便携式的多链光客户端

## 安装

```sh
npm install @a16z/helios
```

也可以使用：`pnpm add @a16z/helios`、`yarn add @a16z/helios`、`bun add @a16z/helios`

## README

# @a16z/helios (韩语)

Helios是一个无信任,高效,可移植的Ethereum光客户端,由TypeScript为web和Node.js环境装订而成. 它同时作为UMD和ES模块而来.

## 安装和基本设置示例

### 1\. 利用国家预防机制安装

安装软件包 :

```bash
npm install @a16z/helios
```

工程的基本用途(例如:, `index.js` 或者说 `index.mjs` 或者说 `main.ts`:

```typescript
import { createHeliosProvider } from '@a16z/helios';

async function main() {
  // Create provider - WASM initialization is handled automatically
  const heliosProvider = await createHeliosProvider({
    executionRpc: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
    consensusRpc: 'https://ethereum.operationsolarstorm.org',
    network: 'mainnet',
    checkpoint: "0x..."
  }, 'ethereum');

  await heliosProvider.waitSynced();
  console.log('Helios is synced and ready!');
  
  // Example: Get latest block number
  const blockNumber = await heliosProvider.request({ method: 'eth_blockNumber', params: [] });
  console.log('Latest block number:', parseInt(blockNumber, 16));
}

main().catch(console.error);
```

### 2\. 从CDN装入网页

对于快速测试,可以像unpkg一样使用CDN在HTML文件中直接尝试Helios.

**作为UMD模块:**

```html
<!DOCTYPE html>
<html>
<head>
  <title>Helios UMD Test</title>
  <script src="https://unpkg.com/@a16z/helios/dist/lib.umd.js"></script>
</head>
<body>
  <script>
    async function main() {
      // Helios is available via global variable `helios`
      const provider = await helios.createHeliosProvider({
        executionRpc: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
        consensusRpc: 'https://ethereum.operationsolarstorm.org',
        network: 'mainnet',
        checkpoint: "0x..."
      }, 'ethereum');
      
      await provider.waitSynced();
      console.log('Helios is ready!');
    }
    
    main().catch(console.error);
  </script>
</body>
</html>
```

**作为ES模块:**

```html
<!DOCTYPE html>
<html>
<head>
  <title>Helios ESM Test</title>
</head>
<body>
  <script type="module">
    import { createHeliosProvider } from 'https://unpkg.com/@a16z/helios/dist/lib.mjs';
    
    async function main() {
      const provider = await createHeliosProvider({
        executionRpc: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
        consensusRpc: 'https://ethereum.operationsolarstorm.org',
        network: 'mainnet',
        checkpoint: "0x..."
      }, 'ethereum');
      
      await provider.waitSynced();
      console.log('Helios is ready!');
    }
    
    main().catch(console.error);
  </script>
</body>
</html>
```

## 作为EIP-1193供应商的使用

赫利俄斯可以用作EIP-1193供应商. 初始化和同步后(如上文实例所示), `heliosProvider` 与viem,ethes.js,web3.js等库一起使用.

有viem的示例:

```typescript
import { createPublicClient, custom } from 'viem';
import { mainnet } from 'viem/chains';
import { createHeliosProvider } from '@a16z/helios';

// Create and sync Helios provider
const heliosProvider = await createHeliosProvider({
  executionRpc: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
  consensusRpc: 'https://lodestar-mainnet.chainsafe.io',
  network: 'mainnet',
  checkpoint: "0x..."
}, 'ethereum');

await heliosProvider.waitSynced();

// Use with viem
const client = createPublicClient({
  chain: mainnet,
  transport: custom(heliosProvider)
});

const blockNumber = await client.getBlockNumber();
console.log('Latest block number:', blockNumber);
```

## 清理

如果赫利俄斯被用作运输工具 `ethers` 或者说 `viem`,电话 `EthersProvider.destroy()` 不破坏赫利俄斯的例子 也不停止背景任务.

适当清理,打电话 `shutdown()` (或其别名) `destroy()`在您的Helios提供方实例中正确释放资源:

```typescript
// Clean up when done
await heliosProvider.shutdown();
```

此程序不订阅所有活动订阅, 中止背景任务, 删除事件听众, 并释放 WASM 内存 。 这种方法具有一能性——多次称呼是安全的. 在引用Helios供应商的例子之后,将收集垃圾.

## 文档

见 [螺旋起重力](https://github.com/a16z/helios/) 更多细节.

## 许可证

这个项目根据麻省理工学院许可证获得许可----详情请见主要存放处.

## 常见问题

### @a16z/helios 是什么？

一个快速、安全和便携式的多链光客户端

### 如何安装 @a16z/helios？

在项目目录运行 npm install @a16z/helios，或使用 pnpm add / yarn add / bun add。

### @a16z/helios 支持 TypeScript 吗？

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

### @a16z/helios 支持 ESM 还是 CommonJS？

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

### @a16z/helios 可以商用吗？

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

### @a16z/helios 的下载量有多少？

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

### @a16z/helios 还在维护吗？

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

