Skip to Content
dApps
On this page

makeInvoice

Request that the user creates an invoice to be used by the web app. This will return a BOLT-11  invoice. Invoices can be requested in a few forms:

  • By specifying an explicit amount, the user’s provider should enforce that the user generate an invoice with a specific amount
  • By specifying a minimumAmount and / or maximumAmount, the user’s provider should enforce that the user generate an invoice with an amount field constrained by that amount
  • When no explicit amount is set, the user can choose an amount within any requested bounds.

Amounts are denominated in satoshis. JavaScript numbers represent integers exactly only up to Number.MAX_SAFE_INTEGER (2^53 - 1). Use a decimal string for values that exceed this range; the API accepts both strings and numbers.

Method

declare function makeInvoice(args: RequestInvoiceArgs): Promise<RequestInvoiceResponse>;

Params

  • args — required object
    • amount — optional string|number the satoshis to send
    • defaultAmount — optional string|number
    • minimumAmount — optional string|number
    • maximumAmount — optional string|number
    • defaultMemo — optional string
interface RequestInvoiceArgs { amount?: string | number; // unit is sats defaultAmount?: string | number; // unit is sats minimumAmount?: string | number; // unit is sats maximumAmount?: string | number; // unit is sats defaultMemo?: string; }

Response

interface RequestInvoiceResponse { paymentRequest: string; paymentHash: string; rHash: string; }

Example

const provider = (window.$onekey && window.$onekey.webln) || window.webln; await provider.enable(); const invoice = await provider.makeInvoice({ amount: 1000, });

Demo

Open example 

Last updated on