Accepts valid redeem codes and rewards users with automatic zaps, note reposts, and private relay whitelist access. Codes can be distributed through product sales, promotions, or any channel you choose. When a user redeems a valid code, the bot triggers the configured reward — zapping their content, reposting their notes, adding their pubkey to a relay whitelist, or any combination of the three.
- Node.js 20 or later
- A Nostr private key (nsec or hex) for the bot account
- A Lightning wallet that supports Nostr Wallet Connect (NWC) — only needed if zapping is enabled
git clone https://github.com/SovITservices/Nostreward.git
cd Nostrewardnpm installCopy the example environment file and fill in your credentials:
cp .env.example .envEdit .env with your values:
BOT_NSEC=nsec1your_private_key_here
NWC_URL=nostr+walletconnect://your_wallet_pubkey?relay=wss://relay.example.com&secret=your_secret_hex
ENABLE_ZAP=true
ENABLE_REPOST=true
ENABLE_WHITELIST=true
See the Configuration section below for all available options.
node manage-codes.js add <code>Codes are stored as SHA-256 hashes in codes.json — the plaintext is never saved to disk. You can add new codes at any time without restarting the bot.
Start the daemon:
npm startThe bot will:
- Connect to the configured Nostr relays
- Subscribe to notes containing the required hashtag (default:
#nostreward) - When a note contains a valid unused redeem code, the bot will:
- Zap the note via NWC (if enabled)
- Repost the note (if enabled)
- Add the author's pubkey to the relay whitelist (if enabled)
- Send a DM to the user if a zap fails, and automatically retry after 30 minutes
# Add a new code
node manage-codes.js add <code>
# List all codes and their status
node manage-codes.js listAll configuration is done through environment variables in the .env file.
| Variable | Required | Default | Description |
|---|---|---|---|
BOT_NSEC |
Yes | -- | The bot's Nostr private key in nsec or hex format |
NWC_URL |
If zapping | -- | Nostr Wallet Connect URL from your Lightning wallet |
RELAYS |
No | wss://relay.primal.net, wss://relay.damus.io |
Comma-separated list of Nostr relay URLs |
ZAP_AMOUNT_SATS |
No | 21 |
Default zap amount in satoshis |
ENABLE_ZAP |
No | false |
Enable Lightning zaps for redeemed codes |
ENABLE_REPOST |
No | false |
Enable note reposts for redeemed codes |
ENABLE_WHITELIST |
No | false |
Enable adding pubkeys to a relay whitelist |
REQUIRED_HASHTAG |
No | nostreward |
Hashtag the bot monitors (without #) |
CODES_FILE |
No | codes.json |
Path to the redeem codes data file |
WHITELIST_FILE |
No | whitelist.json |
Path to the whitelist data file |
The NWC_URL follows the standard Nostr Wallet Connect format:
nostr+walletconnect://<wallet_pubkey>?relay=<relay_url>&secret=<secret_hex>
A Nostr Wallet Connect (NWC) connection string is required when zapping is enabled.
- Go to coinos.io and create an account or log in
- Navigate to Settings then NWC
- Create a new connection and give it a name (e.g., "Nostreward bot")
- Copy the connection string -- it starts with
nostr+walletconnect:// - Paste it as the
NWC_URLvalue in your.envfile
- Set up Alby Hub on your own server
- Go to Settings then Connections
- Click Add a new connection
- Name the connection (e.g., "Nostreward bot") and set a budget if desired
- Copy the pairing URL -- it starts with
nostr+walletconnect:// - Paste it as the
NWC_URLvalue in your.envfile
Primal's NWC implementation has known limitations that can cause issues with automated bots. It only supports NIP-04 encryption and does not send payment confirmation responses (kind 23195 events), which means the bot cannot verify whether a zap succeeded or failed. Payments may still go through, but the lack of confirmation makes it unreliable for automated use. We recommend using Coinos or a self-hosted Alby Hub instead.
Any Lightning wallet that supports NWC (NIP-47) should work. Look for a "Nostr Wallet Connect" option in your wallet's settings and generate a connection string.
nostreward/
src/
index.js - Daemon entry point, note handling, zap retry logic
bot.js - NDK setup, zapping, reposting, DMs, NWC payment logic
codes.js - Redeem code hashing, matching, and persistence
config.js - Environment variable loading and validation
whitelist.js - Relay whitelist management
manage-codes.js - CLI tool for adding and listing redeem codes
.env.example - Example environment configuration
GPL-3.0