@gandlaf21/cashu-ts
TypeScript icon, indicating that this package has built-in type declarations

0.8.0-rc.14 • Public • Published

Cashu TS

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

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

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

Wallet Features:

  • [x] connect to mint (load keys)
  • [x] request minting tokens
  • [x] minting tokens
  • [x] sending tokens (get encoded token for chosen value)
  • [x] receiving tokens
  • [x] melting tokens
  • [x] check if tokens are spent
  • [ ] ...

Implemented NUTs:

Supported token formats:

  • [x] v1 read
  • [x] v2 read (deprecated)
  • [x] v3 read/write

Usage

Go to the docs for detailed usage.

Install

npm i @cashu/cashu-ts

Import

import { CashuMint, CashuWallet, getEncodedToken } from '@cashu/cashu-ts';

const wallet = new CashuWallet(new CashuMint('{MINT_URL}'));

const { pr, hash } = await wallet.requestMint(200);

//pay this LN invoice
console.log({ pr }, { hash });

async function invoiceHasBeenPaid() {
	const proofs = await wallet.requestTokens(200, hash);
	//Encoded proofs can be spent at the mint
	const encoded = getEncodedToken({
		token: [{ mint: '{MINT_URL}', proofs }]
	});
	console.log(encoded);
}

Contribute

Contributions are very welcome.

If you want to contribute, please open an Issue or a PR.

Readme

Keywords

Package Sidebar

Install

npm i @gandlaf21/cashu-ts

Weekly Downloads

0

Version

0.8.0-rc.14

License

MIT

Unpacked Size

1.27 MB

Total Files

112

Last publish

Collaborators

  • gandlaf21