https://github.com/grunch/nostr-publisher-template
https://github.com/grunch/nostr-publisher-template
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/grunch/nostr-publisher-template
- Owner: grunch
- Created: 2026-05-12T17:28:32.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-12T17:57:42.000Z (about 1 month ago)
- Last Synced: 2026-05-12T19:30:44.178Z (about 1 month ago)
- Language: Python
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nostr-publisher-template
Minimal Rust template for publishing notes to Nostr with `nostr-sdk 0.44.1`.
## What it does
- loads `NOSTR_NSEC` or `--secret-key`
- loads relays from `--relay` and/or `NOSTR_RELAYS`
- uses a built-in base relay set if none is provided
- expands the built-in relay set with `--all-relays`
- normalizes relays by removing trailing `/` and deduplicates the list
- publishes a `kind 1` text note
- prints `event_id`, successful relays, and failed relays
- attempts to verify the event by `id` on the configured relays
## Relay priority
1. repeated `--relay` flags in the CLI
2. `NOSTR_RELAYS` as a comma-separated list
3. built-in relays by default
4. if you pass `--all-relays`, the expanded relay list is added too
## Quick start
```bash
cp .env.example .env
# fill in NOSTR_NSEC and, if you want, NOSTR_RELAYS
cargo run -- --content "Hello Nostr"
```
Or with flags:
```bash
cargo run -- \
--secret-key "nsec1..." \
--relay wss://relay.damus.io \
--relay wss://nos.lol/ \
--content "Hello Nostr"
```
To use the expanded relay list:
```bash
cargo run -- --all-relays --content "Hello Nostr"
```
## Notes
- `npub` is not enough to publish.
- If there are no explicit relays, the binary uses the built-in base set.
- Relay verification may take a little while depending on indexing.
- URLs are normalized to remove trailing slashes, so `wss://nos.lol/` and `wss://nos.lol` are treated the same.
- For Notion posts with media:
- the script downloads the attachment and uploads it to nostr.build using `NOSTR_BUILD_NPUB` and `NOSTR_BUILD_PASSWD`
- if the attachment is already hosted on nostr.build, the script reuses that public URL as-is
- the public URL returned by nostr.build is the one used in the Nostr post