Skip to content

An TypeScript library for building Cashu wallets

License

Notifications You must be signed in to change notification settings

BilligsterUser/cashu-ts

 
 

Repository files navigation

Cashu TS

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

⚠️ 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.

Wallet Features:

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

Implemented NUTs:

Supported token formats:

  • v1 read
  • v2 read (deprecated)
  • 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. If you open a PR, please do so from the development branch as the base branch.

Version

* `main`
|\
|\ \
| | * `hotfix`
| |
| * `staging`
| |\ 
| |\ \
| | | * `bugfix`
| | |
| | * `development`  
| | |\ 
| | | * `feature1`
| | | |
| | |/
| | *
| | |\ 
| | | * `feature2`
| | |/
| |/
|/ (create new version)

About

An TypeScript library for building Cashu wallets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%