Zaps e faturas Lightning
Guia de integração e referência de API: Zaps e faturas Lightning.
Esta referência detalhada da API é mantida em inglês e acompanha o código do SDK indicado. Os exemplos com variáveis da aplicação precisam do seu assinador, chaves, armazenamento ou 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.