@cashu/cashu-ts

中文文档
4.13.1发布于 2026/11/11MIT OR Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 8.1万

cashu library for communicating with a cashu mint

原始使用文档
文档目录8 节
  1. Install
  2. Quick Start (Create a wallet)
  3. Usage
  4. Note: Builder hooks vs Global events
  5. Browser usage (standalone build)
  6. Changelog
  7. Contribute
  8. Contact & Community

Cashu TS

GitHub Workflow Status GitHub issues GitHub package.json version npm npm type definitions npm bundle size codecov

⚠️ Don't be reckless: This project is in early development, it does however work with real sats! Always use amounts you don't mind losing.

Cashu TS is a JavaScript library for Cashu wallets written in TypeScript.

Install

npm i @cashu/cashu-ts

ESM-only since v4. This package ships only ES modules. CommonJS require() is no longer supported. If upgrading from v3, see migration-4.0.0.md.

Quick Start (Create a wallet)

There are a number of ways to instantiate a wallet, depending on your needs.

Wallet classes are mostly stateless, so you can instantiate and throw them away as needed. Your app must therefore manage state, such as fetching and storing proofs in a database.

NB: You must always call loadMint() or loadMintFromCache after instantiating a wallet.

import { Wallet } from '@cashu/cashu-ts';

// Simplest: With a mint URL
const mintUrl = 'http://localhost:3338';
const wallet1 = new Wallet(mintUrl); // unit is 'sat'
await wallet1.loadMint(); // wallet is now ready to use

// Persist these in your app
const keychainCache = wallet1.keyChain.cache; // KeyChainCache
const mintInfoCache = wallet1.getMintInfo().cache; // GetInfoResponse

// Advanced: With cached mint data (avoids network calls on startup)
const wallet2 = new Wallet(keychainCache.mintUrl); // unit defaults to 'sat'
wallet2.loadMintFromCache(mintInfoCache, keychainCache);
// wallet2 is now ready to use

Usage

We provide comprehensive examples categorized by use case:

Note: Builder hooks vs Global events

WalletOps builders include per-operation hooks (onCountersReserved) that fire during a single transaction build.

WalletEvents provides global subscriptions (wallet.on.*) that can outlive a single builder call.

Use the builder hooks for transaction-local callbacks, and WalletEvents for app-wide subscriptions.

Browser usage (standalone build)

Cashu TS provides a standalone browser build (IIFE) intended for demos and non-bundler usage. The standalone bundle is published as part of GitHub Releases rather than the npm package.


Changelog

Release notes for every version — across all release lines (current and LTS) — are on the GitHub Releases page.

Contribute

We welcome contributions from anyone — newcomers, experienced developers, and AI-assisted workflows alike.

If you want to contribute:


Contact & Community

We are building in the open and encourage active participation:

  • Join our weekly call — listen, introduce yourself, or ask questions.
  • Participate in our matrix server or telegram channel for ongoing discussion and collaboration.

Being part of the conversation is the best way to have impact and become a long-term contributor.

版本与发布记录

@cashu/cashu-ts 共发布 173 个版本,首次发布于 2023/03/09;过去 12 个月发布了 76 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.13.1latest2026/11/11今天
5.0.0-rc.13next2026/11/11今天
5.0.0-rc.122026/10/2912 天前
4.13.02026/10/2714 天前
5.0.0-experimental.b723385aexperimental2026/10/2418 天前
4.12.02026/10/2021 天前

其他发布通道:v3-lts → 3.7.2,experimental → 5.0.0-experimental.b723385a,next → 5.0.0-rc.13。

关于 @cashu/cashu-ts 的常见问题

@cashu/cashu-ts 是什么?

cashu library for communicating with a cashu mint

如何安装 @cashu/cashu-ts?

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

@cashu/cashu-ts 支持 TypeScript 吗?

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

@cashu/cashu-ts 支持 ESM 还是 CommonJS?

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

@cashu/cashu-ts 需要什么版本的 Node.js?

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

@cashu/cashu-ts 可以商用吗?

@cashu/cashu-ts 使用 MIT OR Apache-2.0 许可。可在 MIT、Apache-2.0 中任选其一遵守。选择 MIT 时,宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cashu/cashu-ts 的下载量有多少?

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

@cashu/cashu-ts 还在维护吗?

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