πͺπ» Deno-based, cloud-native Nostr relay forked from nostream
.
This is a nostr relay, written in Typescript.
This implementation is production-ready. See below for supported features.
The project main repository is available on GitHub.
NIPs with a relay-specific implementation are listed here.
- NIP-01: Basic protocol flow description
- NIP-02: Contact list and petnames
- NIP-04: Encrypted Direct Message
- NIP-05: Mapping Nostr keys to DNS-based internet identifiers
- NIP-09: Event deletion
- NIP-11: Relay information document
- NIP-12: Generic tag queries
- NIP-13: Proof of Work
- NIP-15: End of Stored Events Notice
- NIP-16: Event Treatment
- NIP-20: Command Results
- NIP-22: Event
created_at
Limits - NIP-26: Delegated Event Signing
- NIP-28: Public Chat
- NIP-33: Parameterized Replaceable Events
- NIP-38: Encrypted Group Chat with Megolm group ratchet (Draft)
- NIP-40: Expiration Timestamp
- NIP-42: Authentication of clients to relays
- NIP-45: Event Counts
Todo
- Deno v1.30.x or v1.31.x
- Typescript
- MongoDB 4.4, 5.0, 6.0
- Redis (Standalone Optional, Cluster Required)
- v1.18.8 or later
NOTE: If the payment is enabled, it is recommended to start another instance with
WORKER_TYPE=maintenance
following the "Quick Start" guide.
-
Before you begin
- Complete one of the Quick Start guides in this document
- Create a
.env
file - On
.nostr/settings.yaml
file make the following changes:- Set
payments.enabled
totrue
- Set
payments.feeSchedules.admission.enabled
totrue
- Set
limits.event.pubkey.minBalance
to the minimum balance in msats required to accept events (i.e.1000000
to require a balance of1000
sats)
- Set
- Choose one of the following payment processors:
lnbits
,lnurl
,zebedee
-
-
Complete the step "Before you begin"
-
Create a new wallet on you public LNbits instance
- Demo server must not be used for production
- Your instance must be accessible from the internet and have a valid SSL/TLS certificate
-
Get wallet "Invoice/read key" (in Api docs section of your wallet)
-
set
LNBITS_API_KEY
environment variable with the "Invoice/read key" Key above on your.env
fileLNBITS_API_KEY={YOUR_LNBITS_API_KEY_HERE}
-
On your
.nostr/settings.yaml
file make the following changes:- Set
payments.processor
tolnbits
- set
lnbits.baseURL
to your LNbits instance URL (e.g.https://{YOUR_LNBITS_DOMAIN_HERE}/
) - Set
paymentsProcessors.lnbits.callbackBaseURL
to match your callbcak URL (e.g.https://{YOUR_DOMAIN_HERE}/callbacks/lnbits
)
- Set
-
Restart Denostr
-
-
Alby or any LNURL Provider with LNURL-verify support
- Complete the step "Before you begin"
- Create a new account if you don't have an LNURL
- On your
.nostr/settings.yaml
file make the following changes:- Set
payments.processor
tolnurl
- Set
lnurl.invoiceURL
to your LNURL (e.g.https://getalby.com/lnurlp/your-username
)
- Set
- Restart Denostr
-
- Complete the step "Before you begin"
- Sign up for a ZEBEDEE Developer Dashboard account, create a new LIVE Project, and get that Project's API Key
- Set
ZEBEDEE_API_KEY
environment variable with the API Key above on your.env
file
ZEBEDEE_API_KEY={YOUR_ZEBEDEE_API_KEY_HERE}
- Follow the required steps for all payments processors
- On
.nostr/settings.yaml
file make the following changes:payments.processor
tozebedee
paymentsProcessors.zebedee.callbackBaseURL
to match your callback URL (e.g.https://{YOUR_DOMAIN_HERE}/callbacks/zebedee
)
- Restart Denostr
-
Ensure payments are required for your public key
- Visit https://{YOUR-DOMAIN}/
- You should be presented with a form requesting an admission fee to be paid
- Fill out the form and take the necessary steps to pay the invoice
- Wait until the screen indicates that payment was received
- Add your relay URL to your favorite Nostr client (wss://{YOUR-DOMAIN}) and wait for it to connect
- Send a couple notes to test
- Go to https://websocketking.com/ and connect to your relay (wss://{YOUR_DOMAIN})
- Convert your npub to hexadecimal using a Key Converter
- Send the following JSON message:
["REQ", "payment-test", {"authors":["your-pubkey-in-hexadecimal"]}]
- You should get back the few notes you sent earlier
Clone repository and enter directory:
git clone https://github.com/denostr-lab/denostr.git --depth 1 && cd denostr
Create .env
file inside denostr project folder
Set the following environment variables:
WORKER_TYPE=worker
MONGO_URI=mongodb://user:pass@host:port/db?replicaSet=rs0&authSource=admin
Generate a long random secret and set SECRET:
You may want to use openssl rand -hex 128
to generate a secret.
SECRET=aaabbbccc...dddeeefff
# Secret shortened for brevity
In addition, if using API Key for payments, You must also use the API key of each payment service to set the.
Create .nostr
folder inside denostr project folder and copy over the settings file:
mkdir .nostr
cp resources/default-settings.yaml .nostr/settings.yaml
To start in development mode:
deno task dev
Or, start in production mode:
deno task start
Please refer to this document
Run unit tests with:
deno task test:unit
Run integration tests with:
deno task test:integration
You can change the default folder by setting the NOSTR_CONFIG_DIR
environment variable to a different path.
Run denostr using one of the quick-start guides at least once and denostr/.nostr/settings.json
will be created. Any changes made to the settings file will be read on the next start.
Default settings can be found under resources/default-settings.yaml
. Feel free to copy it to denostr/.nostr/settings.yaml
if you would like to have a settings file before running the relay first.
See CONFIGURATION.md for a detailed explanation of each environment variable and setting.
For development discussions, please use the Nostr Typescript Relay Dev Group.
For discussions about the protocol, please feel free to use the Nostr Telegram Group.
This project is MIT licensed.