diff options
| author | Clawd <ai@clawd.bot> | 2026-02-16 12:12:37 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-16 12:12:37 -0800 |
| commit | 9d20d2281f4698024b7be67d1b86178b4e8e2484 (patch) | |
| tree | f72986f33904afc36b72dd8bbb7d83802fee0479 /README.md | |
| parent | 4b7dfe1e7764d8424b1be935c7fea09a102382e8 (diff) | |
Clean up project structure
- Add README.md
- Move benchmark files to benchmarks/
- Move PLAN.md to .claude/
- Add .gitignore
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..0e7c891 --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | # nostr | ||
| 2 | |||
| 3 | A Go library for the [Nostr protocol](https://github.com/nostr-protocol/nostr). | ||
| 4 | |||
| 5 | ```bash | ||
| 6 | go get code.northwest.io/nostr | ||
| 7 | ``` | ||
| 8 | |||
| 9 | ## Features | ||
| 10 | |||
| 11 | - **Keys** — Generate, parse, and convert between hex/bech32 (npub/nsec) | ||
| 12 | - **Events** — Create, sign, and verify NIP-01 events | ||
| 13 | - **Filters** — Build subscription filters | ||
| 14 | - **Relay** — WebSocket connections with publish/subscribe | ||
| 15 | - **Tags** — Parse and build event tags | ||
| 16 | |||
| 17 | ## Usage | ||
| 18 | |||
| 19 | ```go | ||
| 20 | package main | ||
| 21 | |||
| 22 | import ( | ||
| 23 | "context" | ||
| 24 | "fmt" | ||
| 25 | "code.northwest.io/nostr" | ||
| 26 | ) | ||
| 27 | |||
| 28 | func main() { | ||
| 29 | // Generate a new key pair | ||
| 30 | key, _ := nostr.GenerateKey() | ||
| 31 | fmt.Println("npub:", key.Npub()) | ||
| 32 | |||
| 33 | // Create and sign an event | ||
| 34 | event := &nostr.Event{ | ||
| 35 | Kind: nostr.KindTextNote, | ||
| 36 | Content: "Hello Nostr!", | ||
| 37 | } | ||
| 38 | event.Sign(key) | ||
| 39 | |||
| 40 | // Connect to a relay and publish | ||
| 41 | ctx := context.Background() | ||
| 42 | relay, _ := nostr.Connect(ctx, "wss://relay.damus.io") | ||
| 43 | defer relay.Close() | ||
| 44 | |||
| 45 | relay.Publish(ctx, event) | ||
| 46 | } | ||
| 47 | ``` | ||
| 48 | |||
| 49 | ## Examples | ||
| 50 | |||
| 51 | See [examples/basic](examples/basic) for a complete runnable example. | ||
| 52 | |||
| 53 | ## Benchmarks | ||
| 54 | |||
| 55 | Performance benchmarks are in [benchmarks/](benchmarks/). | ||
| 56 | |||
| 57 | ## License | ||
| 58 | |||
| 59 | MIT | ||
