@shadowylab/webln
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

WebLN - Lightning Web Standard

Getting started

npm i @shadowylab/webln
import { WebLN, loadWasmAsync } from '@shadowylab/webln';

async function webln() {
    // Load WASM
    await loadWasmAsync();

    // Compose new WebLN instance
    let webln = new WebLN();

    // Check if WebLN is enabled
    console.log(await webln.isEnabled());

    // Enable WebLN
    await webln.enable();

    // Get info
    let info = await webln.getInfo();
    console.log(info.alias());
    console.log(info.pubkey());
    console.log(info.color());
    console.log(info.methods());

    // Pay invoice
    await webln.sendPayment("bolt11-invoice");

    // Send payment async (needed for HOLD invoices)
    await webln.sendPaymentAsync("bolt11-invoice");

    let response = await webln.getBalance();
    console.log(response.balance);
}

License

This project is distributed under the MIT software license - see the LICENSE file for details

Donations

⚡ Tips: https://getalby.com/p/yuki

⚡ Lightning Address: yuki@getalby.com

Package Sidebar

Install

npm i @shadowylab/webln

Weekly Downloads

2

Version

0.1.3

License

MIT

Unpacked Size

153 kB

Total Files

6

Last publish

Collaborators

  • yukibtc