Step 1 of 5
One wallet event holds the keys
A replaceable kind 17375 event stores the wallet setup: the mints you trust and a private key used only for receiving locked ecash. All of it is NIP-44 encrypted to yourself, so relays only see ciphertext.
NIP-60
DraftEvents
Keeps an ecash (Cashu) wallet on your relays, encrypted to yourself, so the same balance shows up in every app you sign in to.
Edit the form or the JSON: both stay in sync, the badge says whether the result is valid, and tapping any field explains it.
How the parts connect: Spending from a token
Not signed yet · Demo keys only. These personas' secret keys are public on purpose.
Select any field in the form or the JSON to see what it does.
Step 1 of 5
A replaceable kind 17375 event stores the wallet setup: the mints you trust and a private key used only for receiving locked ecash. All of it is NIP-44 encrypted to yourself, so relays only see ciphertext.
No course chapter covers this NIP yet. The editor above is the quickest way in.
Every wallet, token and history payload is NIP-44 encrypted to the owner.
Spent token events are removed with NIP-09 deletion requests tagged k=7375.
Nutzaps arrive locked to the wallet's private key, and the wallet redeems them.
Mint quote events expire after about two weeks using a NIP-40 expiration tag.
Clients find your wallet on your kind 10019 relays, or your NIP-65 relays as a fallback.
Specification text is quoted in English from the nostr-protocol/nips repository. Our explanations and the interface are translated. Source on GitHub at commit 0046368
This NIP defines the operations of a cashu-based wallet.
A cashu wallet is a wallet which information is stored in relays to make it accessible across applications.
The purpose of this NIP is:
This NIP doesn't deal with users' receiving money from someone else, it's just to keep state of the user's wallet.
kind:17375 event that represents a wallet.kind:7375 events that represent the unspent proofs of the wallet. -- The proofs are encrypted with the user's private key.kind:7376 events that represent the spending history of the wallet -- This history is for informational purposes only and is completely optional.{
"kind": 17375,
"content": nip44_encrypt([
[ "privkey", "hexkey" ],
[ "mint", "https://mint1" ],
[ "mint", "https://mint2" ]
]),
"tags": []
}
The wallet event is an replaceable event kind:17375.
Tags:
mint - Mint(s) this wallet uses -- there MUST be one or more mint tags.privkey - Private key used to unlock P2PK ecash. MUST be stored encrypted in the .content field. This is a different private key exclusively used for the wallet, not associated in any way to the user's Nostr private key -- This is only used for receiving NIP-61 nutzaps.Token events are used to record unspent proofs.
There can be multiple kind:7375 events for the same mint, and multiple proofs inside each kind:7375 event.
{
"kind": 7375,
"content": nip44_encrypt({
"mint": "https://stablenut.umint.cash",
"unit": "sat",
"proofs": [
// one or more proofs in the default cashu format
{
"id": "005c2502034d4f12",
"amount": 1,
"secret": "z+zyxAVLRqN9lEjxuNPSyRJzEstbl69Jc1vtimvtkPg=",
"C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46"
}
],
// tokens that were destroyed in the creation of this token (helps on wallet state transitions)
"del": [ "token-event-id-1", "token-event-id-2" ]
}),
"tags": []
}
.content is a NIP-44 encrypted payload:mint: The mint the proofs belong to.proofs: unencoded proofsunit the base unit the proofs are denominated in (eg: sat, usd, eur). Default: sat if omitted.del: token-ids that were destroyed by the creation of this token. This assists with state transitions.When one or more proofs of a token are spent, the token event should be NIP-09-deleted and, if some proofs are unspent from the same token event, a new token event should be created rolling over the unspent proofs and adding any change outputs to the new token event (the change output should include a del field).
The kind:5 delete event created in the NIP-09 process MUST have a tag ["k", "7375"] to allow easy filtering by clients interested in state transitions.
Clients SHOULD publish kind:7376 events to create a transaction history when their balance changes.
{
"kind": 7376,
"content": nip44_encrypt([
[ "direction", "in" ], // in = received, out = sent
[ "amount", "1" ],
[ "unit", "sat" ],
[ "e", "<event-id-of-created-token>", "", "created" ]
]),
"tags": [
[ "e", "<event-id-of-created-token>", "", "redeemed" ]
]
}
direction - The direction of the transaction; in for received funds, out for sent funds.unit the base unit of the amount (eg: sat, usd, eur). Default: sat if omitted.Clients MUST add e tags to create references of destroyed and created token events along with the marker of the meaning of the tag:
created - A new token event was created.destroyed - A token event was destroyed.redeemed - A NIP-61 nutzap was redeemed.All tags can be NIP-44 encrypted. Clients SHOULD leave e tags with a redeemed marker unencrypted.
Multiple e tags can be added, and should be encrypted, except for tags with the redeemed marker.
A client that wants to check for user's wallets information starts by fetching kind:10019 events from the user's relays, if no event is found, it should fall back to using the user's NIP-65 relays.
From those relays, the client should fetch wallet and token events.
"kinds": [17375, 7375], "authors": ["<my-pubkey>"]
If Alice spends 4 sats from this token event
{
"kind": 7375,
"id": "event-id-1",
"content": nip44_encrypt({
"mint": "https://stablenut.umint.cash",
"unit": "sat",
"proofs": [
{ "id": "1", "amount": 1 },
{ "id": "2", "amount": 2 },
{ "id": "3", "amount": 4 },
{ "id": "4", "amount": 8 },
]
}),
"tags": []
}
Her client:
{
"kind": 7375,
"id": "event-id-2",
"content": nip44_encrypt({
"mint": "https://stablenut.umint.cash",
"unit": "sat",
"proofs": [
{ "id": "1", "amount": 1 },
{ "id": "2", "amount": 2 },
{ "id": "4", "amount": 8 },
],
"del": [ "event-id-1" ]
}),
"tags": []
}
event-id-1event-id-1 to the del array of deleted token-ids.kind:7376 event to record the spend{
"kind": 7376,
"content": nip44_encrypt([
[ "direction", "out" ],
[ "amount", "4" ],
[ "unit", "sat" ],
[ "e", "<event-id-1>", "", "destroyed" ],
[ "e", "<event-id-2>", "", "created" ],
]),
"tags": []
}
When creating a quote at a mint, an event can be used to keep the state of the quote ID, which will be used to check when the quote has been paid. These events should be created with an expiration tag NIP-40 of 2 weeks (which is around the maximum amount of time a Lightning payment may be in-flight).
However, application developers SHOULD use local state when possible and only publish this event when it makes sense in the context of their application.
{
"kind": 7374,
"content": nip44_encrypt("quote-id"),
"tags": [
[ "expiration", "<expiration-timestamp>" ],
[ "mint", "<mint-url>" ]
]
}
Clients can optionally validate proofs to make sure they are not working from an old state; this logic is left up to particular implementations to decide when and why to do it, but if some proofs are checked and deemed to have been spent, the client should delete the token and roll over any unspent proof.