Examples
April 7, 2026 · View on GitHub
Runnable examples for @getalby/lightning-tools.
Setup
cd examples
yarn
yarnlinks the local package viafile:..— if you change library source, rebuild first:cd .. && yarn build && cd examples
Running examples
x402 / L402 — paid API fetch
These examples fetch a URL protected by an HTTP 402 payment wall. You need an NWC connection string.
NWC_URL="nostr+walletconnect://..." yarn 402 # auto-detects L402 or x402
NWC_URL="nostr+walletconnect://..." yarn x402 # x402 only
NWC_URL="nostr+walletconnect://..." yarn l402 # L402 only
Override the default URL:
URL="https://your-402-endpoint.example.com" NWC_URL="nostr+walletconnect://..." yarn 402
Lightning Address — request invoice
Fetches LNURL-pay data for a lightning address and requests an invoice. No credentials needed.
yarn request-invoice
Zaps via NWC
Sends a zap to a lightning address using NWC for payment and a Nostr key for signing.
NOSTR_PRIVATE_KEY="your-hex-private-key" NWC_URL="nostr+walletconnect://..." yarn zaps-nwc