⚡
WebLN Guide
  • Introduction
    • 👋Welcome
    • â„šī¸What is WebLN
    • 🏅Benefits of WebLN
  • Building Lightning Apps
    • 👨‍đŸ’ģ👨đŸ’ģ Getting Started
    • đŸ’ģWebLN Reference
      • 🆕webln.isEnabled()
      • webln.enable()
      • webln.getInfo()
      • webln.keysend()
      • webln.makeInvoice()
      • webln.sendPayment()
      • 🆕webln.sendPaymentAsync()
      • webln.signMessage()
      • webln.verifyMessage()
      • 🆕webln.request()
      • 🆕webln.lnurl()
      • 🆕webln.on()
      • 🆕webln.off()
      • 🆕webln.getBalance()
      • Error handling
    • đŸ› ī¸Libraries and Tools
    • 🔆Best Practices
  • Ressources
    • ⚡WebLN Providers
    • 🚀Showcases
    • 👩‍đŸĢTutorials
    • 🌐Additional Resources
  • Contribute
    • đŸ—ī¸Working Group & Guidelines
    • 📖Glossary
Powered by GitBook
On this page
  • Code Examples
  • Resources
Edit on GitHub
  1. Building Lightning Apps
  2. WebLN Reference

webln.keysend()

Last updated 2 years ago

Request the user to send a keysend payment. This is a spontaneous payment that does not require an invoice and only needs a destination public key and and amount.

Method

async keysend(args: KeysendArgs): SendPaymentResponse;

Parameters

interface KeysendArgs {
  destination: string;
  amount: string | number;
  customRecords?: Record<string, string>;
}
  • destination Hex encoded public key of the destination node. This is a string of length 66 that starts either with 02 or 03.

  • amount The amount of satoshis you want to send as a stringified integer.

  • customRecords A map<string, string> of records that are appended to the payment. The key should be a stringified integer from the . The value should be an unencoded, plain string. The WebLN provider should handle the encoding if necessary. If no custom records are needed, this parameter can be omitted.

Response

interface SendPaymentResponse {
  preimage: string;
}
  • preimage Note that the preimage is not a proof of payment, because unlike a bolt11 payment it is generated by the sender, not by the recipient.

Code Examples

Sending a message

await webln.enable();
const result = await webln.keysend({
    destination: "03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6", 
    amount: "1", 
    customRecords: {
        "34349334": "HELLO AMBOSS"
    }
});

🎧 Podcasting 2.0: Send a boostagram

Manual payments to a podcast or episode and attach your own message.

🎧 Podcasting 2.0: Send a stream payment

Automatic payments while listening to an episode.

Resources

đŸ’ģ
TLV Registry
TLV Registry
Podcasting 2.0 BLIP
Builder's Guide: Sending messages with keysend