Zaps et factures Lightning
Guide d’intégration et référence API : Zaps et factures Lightning.
Cette référence détaillée de l’API est maintenue en anglais et suit le code SDK lié. Les exemples avec des variables applicatives nécessitent votre signataire, vos clés, votre stockage ou votre interface.
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.