Skip to main content

Walkthrough

Start Here

UKey Wallet WebLN Provider brings Lightning Network capabilities into the page. Once the user authorizes the app, it can read node information, request payments, create invoices, or sign messages.

Best For

  • Accepts Lightning Network payments.
  • Generate payment requests for content, services, or account logins.
  • Use Lightning Network-related identities or message signing capabilities.

Setup

1. Install UKey Wallet

Install the UKey Wallet browser extension and confirm that the wallet is available.

2. API injection instructions

  • The UKey Wallet browser extension injects the WebLN Provider into the page.
  • Available portals include window.$ukey.webln and compatible portal window.webln.
  • New projects should read window.$ukey.webln.

The two entrances have the same capabilities, and window.$ukey.webln is more suitable for explicitly choosing UKey Wallet in a multi-wallet environment.

Detect Provider API support

Before calling the WebLN method, please first check whether the Provider exists on the current page:

const provider = (window.$ukey && window.$ukey.webln) || window.webln;

if (!provider) {
alert("Provider unavailable.");
}

Connect to UKey Wallet

Before using payment or signature capabilities, call provider.enable to request user authorization.

const provider = (window.$ukey && window.$ukey.webln) || window.webln;

provider.enable();

After the authorization is completed, continue to call getInfo, sendPayment, makeInvoice and other interfaces.

API

Select the corresponding interface according to business goals:

Events

  • Key Event: Account or network status change.
  • More information: View more