Setting up Payments on Nostr

Setting up Payments on Nostr

Tldr

  • Nostr comes with integrated Bitcoin payments called zaps
  • It’s possible to set up a self-custodial wallet that you host yourself, plus
  • Add all kinds of bells and whistles, like phone app and browser plugin
  • The software I’m using is Albyhub and Phoenixd, deployed with Docker to a cheap VPS
  • I can now receive payments to my Lightning Address rodbishop@getalby.com

Payments on Nostr

One of the great features of Nostr is integrated payments. This feature integrates financial transactions directly into the social network, as a seamless part of using the network.

You can get paid by and pay anyone on the network, to or from anywhere in the world, and for any reason, in a way that is instant and nearly free.

The payments get to be instant and global and free because they are made in Bitcoin, using the Bitcoin payments network called The Lightning Network.

Per Bitcoin, payments are denominated in satoshis (sats). A sat is a one-hundred-millionth of a Bitcoin– US$1 is about 1,700 sats at the time of writing. Making a payment like this on Nostr is called a “zap” and usually indicated with a lightning bolt symbol (you are getting “zapped by lightning”). You might say to your friend ”I'll zap you 1,700 sats”.

This unlocks all kinds of interesting things that are not possible with other social networks, like

  • “value for value”–A publisher publishes something of value and you can tip them if you like it
  • Payments between friends–Nostr can do everything that Cash App and Venmo can do, right down to splitting payments to multiple recipients
  • Payments for creators–you can sell or pay to access premium content similar to any kind of paywall site like Patreon or Substack
  • Payments to AIs–you can pay for automated AI-based services including for translation, image generation, or creating custom curated social media feeds
  • All other kinds of ecommerce–you can sell or buy anything you want similar to Gumtree or Facebook marketplace

Every Nostr user can have this set up. It's free or nearly free to set up, nearly free to make payments, and some apps like Primal will even set it up for you by default.

Moreover it's useful and it's fun.

  • When you help someone out to receive a little tip for doing so, or
  • When you get some great advice to show your appreciation in a more meaningful way than a like

Ways to set up lightning for zaps on Nostr

You can get paid in Bitcoin to a lightning address. This looks exactly like an email address except you can make a payment to it from a lightning wallet.

Anyone can publish their lightning address on Nostr so that you can pay them. And you can also get your own lightning address on your own Nostr profile so that people can pay you.

The lightning address links to a server that’s always active and ready to credit your balance whenever you receive payments.

To make that happen at a high level there are two options, either:

  • Open an account with a custodial lightning provider who will keep an always on server with your wallet on it, live and ready to receive payments for you. Primal does this automatically for you in their Nostr client, or you can use any one of the other popular custodial wallets like Wallet of Satoshi, Zeus, Coinos, or many others
  • Set up your own self-custodial lightning server that runs on an always-on computer or server, which you can administer yourself

Generally using a custodial service will be easier, but comes with the need to trust that third party custodian, and may limit you to pay within their app.

For myself I'm going to self host using Albyhub by npub1getal6ykt05fsz5nqu4uld09nfj3y3qxmv8crys4aeut53unfvlqr80nfm, and Phoenixd by Acinq.

Hosting your own lightning server with Albyhub and Phoenixd

Anyone who's experimented with self-sovereign setups for Bitcoin know that historically there's been quite a bit of heavy lifting.

My number one favourite feature of what Albyhub and Phoenixd have done together is to create a nearly instant set up with no heavy lifting. I was stunned. For anyone who's used to jumping through hoops with this, it was like magic.

You can use Albyhub with any lightning wallet backend, but in my view none are as automatic, and magic, as Phoenixd.

Compare the traditional set up with the Albyhub and Phoenixd setup.

Traditional–

  • Set up a Bitcoin core node
  • Download the entire Bitcoin blockchain (wait several days for it to download)
  • Set up a Bitcoin lightning node
  • Purchase payment liquidity to enable payments to the network
  • On an ongoing basis continue to keep your blockchain in sync with the network
  • On an ongoing basis manage your inbound and outbound liquidity to your network peers

Vs Albyhub and Phoenixd–

  • No Bitcoin core
  • No initial block download
  • Phoenixd provides liquidity for you automatically and by default
  • Nothing to keep in sync with the network
  • No liquidity to manage

For any normal non-technical user, self-hosting your own lightning node just went from being too hard, to very achievable.

Unpacking the parts

There are a few parts to this set up and there’s a bit of assumed knowledge here, so let’s quickly unpack it

  • Bitcoin–money for the internet, which enables payments to and from anywhere
  • Lightning–the main payments network that sits on top of Bitcoin, which makes transactions instantly and with very low fees
  • Phoenixd–a lightning wallet back-end with special methods for managing liquidity that makes it almost no-touch to set up and manage
  • Albyhub–a lightning front-end with an easy to-use wallet, and a feature called “Nostr Wallet Connect” (NWC) which connects the wallet to Nostr
  • AlbyGo–a phone app so you can make payments on your phone
  • Alby Plugin–a web browser plugin so you can make payments on your browser, and also log into Nostr from your browser (using NIP-07)
  • NWC–a method for connecting your wallet directly to Nostr apps so that you can spend from your wallet balance without even leaving the app
  • Lightning Address–an address like an email address where you can receive payments (using LNURLp; Lightning Network URL)

I'm going to plug it all together, so that I can pay for anything in any way I like (from NWC, Alby Plugin or Alby Go), and receive payment from anyone (to our Lightning Address), with all funds managed on my own server (hosting Albyhub and Phoenixd).

How to set up Albyhub and Phoenixd

To set this up requires basic command line knowledge, and some experience with Docker. I didn’t have that experience, so I gave ChatGPT the docs on each of Albyhub and Phoenixd and it walked me through the setup.

To start with, I got myself a cheap VPS, and installed Docker. Docker then allowed me to deploy Albyhub and Phoenixd as a container.

The Albyhub Github contains very helpful readme, here https://github.com/getAlby/hub

And Phoenixds own docs here https://phoenix.acinq.co/server and here https://github.com/ACINQ/phoenixd

Alby also has a dedicated section to working with Albyhub with Phoenixd backend, here https://github.com/getAlby/hub/blob/master/scripts/linux-x86_64/phoenixd/README.md

First, install Docker and make sure it is running.

Then working with the code on the Albyhub with Phoenixd page–

  • Get the docker-compose.yml file which will instruct Docker to create the relevant containers,
  • Create the directories for the files to be stored in
  • Launch the containers

That’s it. Docker will proceed to create the application for you running on port 8080

You can then log in in a web browser and start the setup–

  • There’s a helpful step-by-step guide to walk you through the set up including to set up a password for your hub
  • It will ask you to connect your Alby account. I skipped that step as I didn’t have one at the time, I only created one later
  • If you used the default lightning back-end, Alby will then ask you to buy your first liquidity to enable you to make payments. Or, if you are using Phoenixd, then the step is automatic and you can go right ahead to transfer in some initial funds

Setting up the bells and whistles

That's the hard part done. The next step is add all the little extra pieces that make for a great Nostr experience.

Alby Browser Plugin–

  • Download the Alby Browser Plugin to your web browser and create an account
  • It will give you a new Nostr and Lightning account by default, and you can replace it
  • For me I had my own keys already saved with a mnemonic backup, and I wanted to use these. I went to Settings and clicked “Remove Master Key”, then entered the mnemonic backup of my own keys. I also went to Nostr Settings and clicked “Derive from Master Key” to replace the one it generated by default.
  • Visit Albyhub, and connect the Alby Account
  • This completes the set up to login and zap with Nostr on any Nostr site

Alby Go App

  • Download the Alby Go App to your phone from your phone’s app store
  • Vist Albyhub, go to the Alby App Store, and click Alby Go
  • It will help you to create a connection between your Albyhub and Alby Go

Nostr Wallet Connect

  • You can use the Alby App Store to connect any Nostr app in the same way
  • Vist Albyhub, go to the Alby App Store, and click on any Nostr App
  • I used Amethyst, and I was able to create a connection between Amethyst Nostr app and Albyhub, so that when I click the “zap” icon in Amethyst it can automatically spend from my Albyhub wallet without any further clicks

Your own Lightning Address

  • Your Alby Account in your Alby Browser Plugin gives you a Lightning Address by default. It is generated randomly to start with, and you can replace it.
  • Open the Alby Browser Plugin and visit Settings
  • Click “Change on getalby.com” and change it to something that suits you
  • I changed mine to rodbishop@getalby.com

That completes the set up.

Backups

Now that everything is set up, it’s time to make a backup.

I already had my Nostr keys as a mnemonic backup from my last article, and I’m using these keys for my Alby Account, so there is nothing new to back up there.

But we still need backups for the Albyhub login credentials, and the Phoenixd wallet.

When started for the first time, Phoenixd will generate a 12-word mnemonic of its own, which it will use to restore your wallet balance in case of any issue. This recovery phrase is stored in the phoenix folder you created, at ~/.phoenixd/seed.dat.

In total, your backups will contain:

  • Your 12 word mnemonic backup of your Nostr keys, that is also the same master 12 word mnemonic for your Alby account
  • Your 12 word mnemonic backup for your Phoenixd wallet, that is created by the daemon when it first runs at ~/.phoenixd/seed.dat
  • Three passwords: 1) Your password for your Alby account, 2) Your password for your Alby Hub, 3) Your password for your Phoenixd (that is hardcoded into the docker-compose.yml)

Once these are backed up somewhere safely, you can fully recover your set up if ever anything goes wrong.

Things I did wrong in set up so that you don’t have to

Initially I had some trouble with user permissions. I was able to resolve it by changing the user configuration in the docker-compose.yml.

I also had some trouble with the initial funds transfer. In order to test everything without risking significant funds, I made an initial transfer to the hub of 10 satoshis.

  • The transfer was received immediately, but
  • The available balance stayed at zero, and
  • I couldn’t make any payments (insufficient funds)

I thought this was a bug in my set up, but it turns out this is a feature of Phoenixd auto-liquidity, that it keeps some initial sats as a payment credit to buy the required lightning channel liquidity. The total cost amounts to on average 1% charge, but it is also front-loaded, and because my payment was so very tiny (10 satoshis worth a fraction of a cent) the payment was entirely front-loaded.

I diagnosed this by accessing Phoenixd directly in the cli, and by doing so, I was able to see the balance present, as a fee credit.

To check, run–

  • docker-compose exec albyhub-phoenixd /phoenix/bin/phoenix-cli --http-password=<your-password-here> getbalance

And receive a response like this, which shows the credit on the account –

  • { "balanceSat": 0, "feeCreditSat": 10 }

The above command–

  • accesses the albyhub-phoenixd container “docker-compose exec albyhub-phoenixd”,
  • then accesses the phoenix-cli application at “/phoenix/bin/phoenix-cli”
  • and asks the application to “getbalance”

Helpful docs–

I wondered what the total initial amount would be that would be captured as fee credit. Your mileage might vary, but for me:

  • I transferred in 2,100 sats (about $1.20)
  • I received a working balance of 775 sats, so I paid 1,325 sats in fees
  • I then transferred in another 2,100 sats
  • I received all 2,100 sats (paid no fees at all on the second transaction)

All up only a few cents to get started with initial liquidity.

In summary

Nostr has integrated payments that are instant and nearly free, using Satoshis on the Lightning Network. Some Nostr clients come with a wallet set up automatically, and it is quite easy to set up your own self-custody wallet, with all the bells and whistles.

I wanted to set up my own self-custody wallet so that I could test and learn the full set up of the system. For this I used Albyhub and Phoenixd, and I deployed it to a cheap VPS using Docker.

Once set up, I added all the extra bits so that now–

  • I can login to Nostr from my web browser with the Alby Browser Plugin
  • I can make payments from there too, or from the AlbyGo App, or from any Nostr app I like
  • I can receive payments to my Lightning Address rodbishop@getalby.com

And in doing this–

  • I don’t rely on any third-party custodian to take care of my funds
  • I had no hard work to install this setup, and expect no ongoing admin to keep it running
  • With everything set up, the system simply works (so far!)

For anyone interested in Nostr or Bitcoin software or technologies, I recommend to go through a set up like this as it really covers the full gamut or the Nostr–Lightning–Bitcoin stack. It’s clear how far this technology has come and how powerful it can get from here.

Up next

  • Please let me know if this kind of post is helpful or anything you’d like me to improve or expand upon
  • For my next post I’ll show how I set up Nostr and lightning addresses at your own domain with Sveltekit and Vercel