Runnable examples for @getalby/lightning-tools.
cd examples
yarn
yarnlinks the local package viafile:..— if you change library source, rebuild first:cd .. && yarn build && cd examples
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 onlyOverride the default URL:
URL="https://your-402-endpoint.example.com" NWC_URL="nostr+walletconnect://..." yarn 402Fetches LNURL-pay data for a lightning address and requests an invoice. No credentials needed.
yarn request-invoiceSends 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