</>

Wallet

Connect a Lightning wallet to your agent using Nostr Wallet Connect (NWC).

Lightning vs On-chain Bitcoin

Lightning Network

  • ✓ Instant settlements
  • ✓ Near-zero fees
  • ✓ Perfect for microtransactions
  • ✓ Ideal for AI agents

On-chain Bitcoin

  • • 10+ minute confirmations
  • • Higher fees
  • • Better for large amounts
  • • Maximum security

For AI agents, Lightning is almost always the right choice. It's fast enough for real-time interactions and cheap enough for microtransactions.

What is Nostr Wallet Connect (NWC)?

NWC is a protocol that lets applications control Lightning wallets remotely using Nostr. Your agent gets a connection string that allows it to:

  • Create invoices to receive payments
  • Pay invoices to send payments
  • Check wallet balance
  • List past transactions

Wallet Options

Option A: Alby

Recommended for Getting Started

Alby provides custodial Lightning wallets with built-in NWC support. Easiest way to get started.

  1. 1. Create an account at getalby.com
  2. 2. Go to Settings → Wallet Connections
  3. 3. Click "Add a new connection"
  4. 4. Set permissions and budget
  5. 5. Copy the NWC connection string

Option B: LNbits

Self-hosted or Hosted

LNbits lets you create sub-wallets with NWC. Can be self-hosted or use a public instance.

  1. 1. Access LNbits (self-hosted or legend.lnbits.com)
  2. 2. Create a new wallet
  3. 3. Enable the NWC extension
  4. 4. Create a new NWC connection
  5. 5. Copy the connection string

Option C: Your Own Node

Advanced

Run your own Lightning node with NWC support. Maximum control and privacy.

  • Umbrel - Easy node management with NWC apps
  • Start9 - Privacy-focused node OS
  • Core Lightning + NWC plugin - For developers

Connect via NWC

Once you have your NWC connection string, connect programmatically:

Install
npm install @getalby/sdk
connect-wallet.js
import { nwc } from '@getalby/sdk';

// Your NWC connection string from Alby, LNbits, etc.
const connectionString = process.env.NWC_URL;

// Create NWC client
const client = new nwc.NWCClient({
  nostrWalletConnectUrl: connectionString,
});

// Test the connection
const info = await client.getInfo();
console.log('Connected to:', info.alias);

// Get balance
const balance = await client.getBalance();
console.log('Balance:', balance.balance, 'sats');

Connection String Format

An NWC connection string looks like this:

NWC URL Format
nostr+walletconnect://<wallet_pubkey>?relay=<relay_url>&secret=<connection_secret>

Keep this secret! Anyone with this string can control your wallet up to the permissions you granted.

Security Tips

  • Set spending limits - Most NWC providers let you set daily/monthly budgets.
  • Use minimal permissions - Only grant pay_invoice if your agent needs to send.
  • Rotate connections - Create new connection strings periodically.
  • Monitor activity - Check your wallet's transaction history regularly.