Adding accounts

Programmatically add new wallet connections and allow users to connect their account to Alby with a click of a button.

Albys extension APIs are provided via the window.alby object (very much like WebLN). You don't need to add any dependencies or packages to your project.

API

async function addAccount(request: AddAccountRequest) : AddAccountResponse;

interface AddAccountRequest = {
    name: string;
    connector: string;
    config: object;
}

interface AddAccountResponse = {
    success: boolean;
    error: string?;
}

Name

The display name for the account you want to add to Alby. (this can be changed by users later on, but make sure to provide some recognizable name)

Connector

The parameters vary depending on the type of account you want to add. The following types are available:

  • citadel *

  • commando (Core Lightning)

  • eclair

  • galoy

  • kollider

  • lnbits *

  • lnc (Lightning Node Connect)

  • lnd *

  • lndhub *

* Prefix the type with native if you want to connect via TOR (e.g. nativelnd)

Config

The config contains credentials to connect to the users wallet, they differ by the connector you are trying to connect. Take a look into our repository, choose the connector you are about to add and look for the config object:

https://github.com/getAlby/lightning-browser-extension/tree/master/src/app/screens/connectors

This should give you an idea of what parameters need to be provided. Feel free to reach out to us at support@getalby.com in case of any questions, we're happy to help!

Code Example

await window.alby.enable();
const result = await window.alby.addAccount({
  name: "⚡️ LNbits (legend.lnbits.com)", 
  connector: "lnbits", 
  config: {
    "adminkey": "...",
    "url": "https://legend.lnbits.com"
  }
});

Screenshots

Demo

Last updated

Logo

Your bitcoin & nostr companion / from 🐝 with 🧡