Login to reply
Replies (26)
I figured out how to generate a Version 3 or 4 encoded cashu token
Neither were able to accepted by cashu.me or enuts wallets
What am I doing wrong?
I assume you have read the documentation?
@cashu/cashu-ts
Documentation for @cashu/cashu-ts
I was able to figure it out, but then ran into this problem:
View quoted note β
What's the error?
Version 3 token crashes eNuts and wonβt be received after paste on Cashu.me:
cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJhbW91bnQiOjIsIkMiOiIwMjY1ZjdiNmYzMDI0ZTRiNjU4MWVkODkxZTRkMGIyZDU2MzRmMmQxM2NjMDE4MGFkOWZkMzNmYTZkOTdhY2ZhYjIiLCJpZCI6IjAwNTAwNTUwZjA0OTQxNDYiLCJzZWNyZXQiOiI5MDg2YTU2ZTAxODliZWFjMzhkM2Q1ZTFhYWE1ZjI0ZWY4NDljZTI0YjkyNzBkOTQ1NDVjMmMyODk2YjNiMGNhIn1dfV19 iffddffff
Version 4 token says itβs invalid or already spent on eNuts and wonβt be received after paste on Cashu.me:
cashuBo2Ft92F1Y3NhdGF0gaJhaUgAUAVQ8ElBRmFwgaRhYQJhc3hAMjg2MzYxODBkZGI5YTZiZTM3MzUwZmM4OGQyOWQ3MDE0YWUxNjMzNmJhYzUyNTBlMmE4ZDIxNGU2NTMxZGExNmFjWCEChg1psn9suvjrDc-Y3N_WzyoeRAmSTQx8gYlUE-N6A29hZKNhZVggHmLx5fkeImRxJlUY3s-bLH53zg7VASoNhkXXs_AdbThhc1ggYpycvOtXjR_cph9QB_-3RpqM02_7wD5gSat6HLSIK9BhclggssWFdqjEdrPcsI-Q6ZJ9-3cJ9ruJUdDN3I3tD7l5FBk
You are missing the mint url in the object that is being encoded.
Updated this line to include mintUrl:
const cashuToken = getEncodedToken({ mint: mintUrl, proofs: send }, { version: 4 });
I was able to generate the token and receive it on cashu.me, but still get an error on eNuts that the token is invalid or already used π€
The first argument to getEncodedToken should by of type Token: 

Creating a Token | Cashu-TS Docs
A Token is what we use when we transfer money from one wallet to another. Technically speaking a Token is an object containing a list of Proofs and...
enuts is not maintained and does not support Cashu v1 api or v4 token encoding
Ok cool, thanks for your help!
Is v3 the most widely accepted token version?
Iβm not familiar with the differences. I tried looking it up, but not sure where v3 and v4 tokens are defined.
Sorry for hassling, but I appreciate the help!
I don't understand why I'm seeing this error:
"Not enough funds available (1) for swap amountToSend: 1 + fee: 0 | length: 1"
To me this means:
1 sat is available.
1 sat is intended to be sent.
No fee.
1 proof of 1 sat to send.
Yet 1 sat is not enough to send 1 sat?
From this code:
cashu-ts/blob/main/src/CashuWallet.ts


No worries! Happy to help. Can you send me your code? Are you sure that fees are 0?
I'm pretty sure it's related to my code and not the cashu-ts library
When I run the cashu-ts pure typescript in terminal I have no issue minting 1 sat and generating a token
I tried to build a webpack version of cashu-ts so I could easily integrate it into my webapp
The error arises when I try to execute the sendTokens command:
const { keep, send, cashuToken } = await CashuBuddy.sendTokens(wallet, secretAmount.value, proofs, secretInput.value);
Here's the webpack code for reference:

GitHub
cashubuddy/src/index.ts at main Β· happylemonprogramming/cashubuddy
Cashu webpack built from cashu-ts to pure javascript so it can be loaded into webapps - happylemonprogramming/cashubuddy
I think I figured it out actually
Thanks for your help π
Awesome! What turned out to be the issue?
Iβm not familiar with typescript so I just kept struggling and stumbling through it
Hereβs what I eventually did and maybe you can tell me if there was an easier way
-Created a typescript project folder
-npm installed your library
-Created a file to export each function I needed (see image below)
-Packaged it into a webpack
-npm run build to get bundle.js file
-Host bundle.js on cloudflare
Now my webapp has your functions and all I need in my HTML is:
β<script src="https://cashubuddy.pages.dev/bundle.js"></script>β


Great! The package actually already has an inbuilt command to create a standalone bundle. Simply clone the repo and do
- npm i
- npm run compile:standalone
@lemon alternatively you can use Macadamia on iOS which supports v4 (at least in TestFlight):
macadamia Wallet
macadamia Wallet for iOS
I forgot about macadamia, thanks!
Is it still in active development?
lol nice, thatβs way easier
At least it was a good learning experience π
Is the standalone bundle already hosted on a CDN anywhere?
I could at least do that if that benefits anyone
I think so, it was updated recently
I got this error in the image below because I'm on an old Windows machine
I had to:
- npm i
- npm install --save-dev cross-env
- update "compile:standalone": "cross-env BUILD_FORMAT=iife vite build" on package.json
- npm run compile:standalone
But now I think I got the full cashu-ts library working! Thanks for your help!


Can I lock e-cash to an npub using cashu-ts?
Yes, you can lock to schnorr public keys. Just make sure to convert them accordingly
