Zaps and Lightning invoices
Build zap requests and obtain invoices for notes or profiles.
This detailed API reference is maintained in English and follows the linked SDK source. Code examples with application variables need your own signer, keys, storage or UI.
NIP-57 — Zaps
The full zap flow: discover the recipient's LNURL endpoint from their profile, build a kind-9734 zap request, hit the LNURL callback, get back a BOLT11 invoice ready to pay.
ts
import { requestZapInvoice } from "@nostr-wot/wallet";
import { Nip07Signer } from "nostr-wot-sdk/signers";
const signer = new Nip07Signer();
const { invoice, zapRequest } = await requestZapInvoice(signer, {
recipientPubkey: "hex...",
amountMsats: 21_000, // 21 sats
comment: "great post",
relays: ["wss://relay.damus.io"],
lud16: "alice@getalby.com", // optional; auto-discovered if omitted
eventId: "abc...", // for note zaps; omit for profile zaps
});
// Pay the invoice via NWC, WebLN, or any wallet
await nwcClient.payInvoice({ invoice });The zap receipt (kind-9735) lands on the recipient's relays once the LNURL service publishes it; consumers can subscribe to kinds: [9735], #e: [eventId] to count zaps. The parseZapMsats helper in nostr-wot-sdk/data decodes the receipt's bolt11 amount.
Lower-level
ts
import { buildZapRequest } from "@nostr-wot/wallet";
const { event, encoded } = await buildZapRequest(signer, {
recipientPubkey,
amountMsats: 21_000,
comment: "...",
relays,
eventId,
});
// Append `?nostr=${encoded}&amount=${amountMsats}&comment=...` to the
// recipient's LNURL-pay callback yourself, parse the invoice from
// the JSON response.