{"id":21110060,"url":"https://github.com/ebrakke/cashu-wallet","last_synced_at":"2026-01-18T04:08:46.958Z","repository":{"id":226240466,"uuid":"768144219","full_name":"ebrakke/cashu-wallet","owner":"ebrakke","description":"A framework agnostic cashu wallet written in typescript.","archived":false,"fork":false,"pushed_at":"2024-03-24T17:34:34.000Z","size":914,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-20T00:57:46.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ebrakke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-06T14:51:20.000Z","updated_at":"2024-06-07T15:29:23.000Z","dependencies_parsed_at":"2024-03-19T18:58:49.021Z","dependency_job_id":null,"html_url":"https://github.com/ebrakke/cashu-wallet","commit_stats":null,"previous_names":["ebrakke/cashu-wallet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ebrakke/cashu-wallet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebrakke%2Fcashu-wallet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebrakke%2Fcashu-wallet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebrakke%2Fcashu-wallet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebrakke%2Fcashu-wallet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ebrakke","download_url":"https://codeload.github.com/ebrakke/cashu-wallet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebrakke%2Fcashu-wallet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28529456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T00:57:43.604Z","updated_at":"2026-01-18T04:08:46.943Z","avatar_url":"https://github.com/ebrakke.png","language":"TypeScript","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Cashu Wallet\n\nA bare bones [cashu](https://cashu.space) wallet implementation that can be used in any javascript application.\n\n**NOTE**: This is super rough an early, and not feature complete. Please don't use in production!\n\n## Background\n\nCashu wallets all (more or less) have the same basic features when it comes to state. We need to track the tokens which are minted, track invoices, and allow users to send and receive both ecash and lightning.\n\nThe UX for these wallets will differ based on use case, but the internals shouldn't change much. Leveraging [cashu-ts](https://github.com/cashubtc/cashu-ts), `cashu-wallet` adds a stateful layer which can be used in any web application.\n\nThe building block is the `Wallet` class, which handles mint connections and exposes the following interface\n\n```ts\ninterface IWallet {\n  state$: Observable\u003cWalletState\u003e;\n  state: WalletState; // A getter for the current state\n  receive(payload: ReceivePayload): Promise\u003cvoid | string\u003e;\n  send(payload: SendPayload): Promise\u003cstring | void\u003e;\n}\n```\n\nThis provides the bare bones functionality that one might want to do with a cashu wallet. By utilizing RxJS, we have a framework agnostic way to tap into reactivity. Framework plugins can make it easier to use in a specific scenario, but are not required to just get a wallet running in your application.\n\n## Use cases\n\n- Embed in a nostr client\n- A gambling app that may want every user to have an ecash wallet\n- A web based RPG in which currencies are backed with ecash mints.\n\n## Features\n\n- Reactivity built in using RxJS\n- Framework Agnostic\n\n![sample-app](./docs/sample-app.png)\n\n## TODO\n\nCreate adapters for:\n\n- [x] React (hook)\n- [x] Svelte (store)\n- [ ] Vue (pinia store)\n\n- [ ] Better documentation\n- [x] Better sample application\n- [x] Cleanup dependencies\n- [x] Make this a library\n- [ ] Publish to npm\n\n## Installation\n\n1. Clone the repository: `git clone https://github.com/ebrakke/cashu-wallet.git`\n2. Install dependencies: `pnpm install`\n3. Build packages: `pnpm build`\n\nNow you can run any of the example applications in `examples`. Navigate to the example you wish to run and run `pnpm dev`\n\n## Usage\n\n```ts\n// Single mint\nimport { SingleMintWallet, LocalStorageProvider } from \"@cashu-wallet/core\";\n\nconst wallet = new SingleMintWallet(\n  \"minibits\",\n  \"https://mint.minitbits.cash/Bitcoin\",\n  new LocalStorageProvider(\"minibits-wallet\")\n);\n\n// lightning\nconst invoice = await wallet.receiveLightning(100); // Generates an invoice to fund the wallet\nawait wallet.payLightning(invoice); // Pays an invoice with e-cash\n\n// E-Cash\nawait wallet.receiveEcash(token); // redeems an ecash token. Token must be the same mint as the wallet\nconst token = await wallet.sendEcash(amount); // Creates a spendable e-cash token\nawait wallet.swap(token); // Receive an e-cash token from another mint and swap it to the wallet's mint\n\n// State\nwallet.state; // returns a snapshot of the current wallet state. See WalletState for more details\nwallet.state$; // returns an observable of the current wallet state\n\n// Utilities\nwallet.pruneSpentTokens(); // Removes any spent ecash tokens from the wallet state\nwallet.prunePaidInvoices(); // Removes any paid invoices from the wallet state\nwallet.dump(); // Returns a JSON stringified version of the wallet state\nSingleMintWallet.loadFromSyncStorage(key, storageProvider); // Wallet factory to load wallets from sync storage\nSingleMintWallet.loadFromAsyncStorage(key, storageProvider); // Factory to create a wallet stored with async storage\n\n// Multi Mint\nimport { MultiMintWallet, LocalStorageProvider } from \"@cashu-wallet/core\";\nconst wallets = new MultiMintWallet(\n  (id: string, mintUrl: string) =\u003e StorageProvider\n);\n\n// Wallet Management\nwallets.add(\"minibits\", \"https://mint.minibits.cash/Bitcoin\");\nwallets.setDefault(\"minibits\"); // First wallet added is the default wallet by default\nconst wallet = wallets.getWallet(\"minibits\"); // Gets an instance of SingleMintWallet\n\nwallets.state; // Snapshot of the multi wallet state. See MultiMintWalletState for more details\nwallets.state$; // Observable of the multi wallet state\n```\n\n### Wallet State\n\n```ts\ntype WalletState = {\n  balance: number; // The sum of all of the valid proofs in the wallet\n  transactions: Record\u003cstring, Transaction\u003e; // A record of E-Cash and Lightning transactions\n  mintUrl: string; // The mintUrl of the wallet\n  id: string; // The ID of the wallet\n};\n```\n\n### Multi Wallet State\n\n```ts\ntype MultiMintWalletState = {\n  balance: number; // The sum of proofs across all wallets\n  defaultWallet: string; // The ID of the default wallet\n  walletIds: string[]; // The IDs of all the wallets in the wallet state\n};\n```\n\n## Contributing\n\nContributions are welcome! Please follow the guidelines in [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febrakke%2Fcashu-wallet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febrakke%2Fcashu-wallet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febrakke%2Fcashu-wallet/lists"}