@ethersphere/core-sdk

中文文档
0.3.0发布于 2026/10/27BSD-3-ClauseTypeScriptESM + CJS构建来源已验证近 30 天下载 8473

Framework-agnostic TypeScript primitives for the Swarm decentralised storage network

原始使用文档
文档目录4 节
  1. Install
  2. Quick example
  3. What's included
  4. Development

Swarm Core

Framework-agnostic TypeScript primitives for the Swarm decentralised storage network: typed byte wrappers, content-addressed and single-owner chunks, the Mantaray manifest trie, Reed-Solomon erasure coding, encryption, and postage stamp signing.

No network I/O — this library only builds and parses Swarm's on-disk/on-wire data structures. Talking to a Bee node is left to the consumer (e.g. bee-js).

Install

npm install @ethersphere/core-sdk

Ships as both ESM and CommonJS, with full TypeScript types. Import from the subpath you need:

import { Bytes, Reference } from '@ethersphere/core-sdk/bytes'
import { makeContentAddressedChunk } from '@ethersphere/core-sdk/chunk'

Quick example

import { makeContentAddressedChunk } from '@ethersphere/core-sdk/chunk'

const chunk = makeContentAddressedChunk('Hello, Swarm!')
console.log(chunk.address.toHex())

What's included

SubpathContents
@ethersphere/core-sdk/bytesBytes and typed wrappers (Reference, BatchId, EthAddress, PrivateKey, PublicKey, Signature, Span, Topic, Identifier, FeedIndex, PeerAddress, TransactionId) plus low-level encoding helpers (hex/base32/base64, concat, slice, integer packing)
@ethersphere/core-sdk/cryptoKeccak-256, ECDSA sign/recover/verify, public/private key derivation
@ethersphere/core-sdk/chunkContent Addressed Chunks (CAC), Single Owner Chunks (SOC/SOC replicas), the BMT chunk hash, and ChunkSplitter/ChunkJoiner for building and reconstructing chunk trees
@ethersphere/core-sdk/mantarayMantarayNode — the manifest trie used for directory/collection uploads
@ethersphere/core-sdk/erasure-codingReed-Solomon parity, redundancy-level tables, and the batching logic used to add parity chunks to a stream
@ethersphere/core-sdk/encryptionChunk-level stream cipher and XOR helpers
@ethersphere/core-sdk/bpsBPS-lite live pub/sub (SWIP-74/87): session topics and chunk ids, signed DATA/AUTH/ROSTER/EOS chunks, WebSocket frame codecs, roster payloads, and BpsPosition for resuming a subscription
@ethersphere/core-sdk/stamperPostage stamp signing (Stamper, stamp()) and effective-capacity math

Every subpath is also re-exported from the package root (@ethersphere/core-sdk), so import { Bytes } from '@ethersphere/core-sdk' works too.

Development

pnpm install
pnpm test          # vitest
pnpm typecheck
pnpm format:check
pnpm build          # esbuild (ESM + CJS) + tsc (.d.ts)
pnpm bench          # perf-sensitive functions, checked against a stored baseline

Requires Node.js 22+.

版本与发布记录

@ethersphere/core-sdk 共发布 6 个版本,首次发布于 2026/08/18;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.0latest2026/10/2717 天前
0.2.22026/10/131 个月前
0.2.12026/09/281 个月前
0.2.02026/09/251 个月前
0.1.12026/08/182 个月前
0.0.12026/08/182 个月前

关于 @ethersphere/core-sdk 的常见问题

@ethersphere/core-sdk 是什么?

Framework-agnostic TypeScript primitives for the Swarm decentralised storage network

如何安装 @ethersphere/core-sdk?

在项目目录运行 npm install @ethersphere/core-sdk,或使用 pnpm add / yarn add / bun add。

@ethersphere/core-sdk 支持 TypeScript 吗?

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

@ethersphere/core-sdk 支持 ESM 还是 CommonJS?

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

@ethersphere/core-sdk 需要什么版本的 Node.js?

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

@ethersphere/core-sdk 可以商用吗?

@ethersphere/core-sdk 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@ethersphere/core-sdk 的下载量有多少?

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

@ethersphere/core-sdk 还在维护吗?

最新版本 0.3.0 发布于 2026/10/27(17 天前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/08/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。