nmostr

Library for working with the Nostr protocol.

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 0.1.1
License AGPL-3.0-only
CI Status Failing
Downloads 0
Last Indexed 2026-08-04 05:10

Authors

  • Gruruya

Installation

nimble install nmostr
choosenim install nmostr
git clone https://github.com/Gruruya/nmostr

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
nmostr - - - - - -

Dependencies

Package Version Optional
nim >= 2.0.0 No
jsony >= 1.1.5 & < 1.2.0 No
secp256k1 >= 0.6.0.3.2 No
crunchy >= 0.1.9 & < 0.2.0 No
stack_strings >= 1.1.4 & < 1.2.0 No
stew - No
https://github.com/alaviss/union >= 0.2.0 & < 0.3.0 No
weave >= 0.4.10 & < 0.5.0 No

Source

Repository https://github.com/Gruruya/nmostr
Homepage https://github.com/Gruruya/nmostr
Registry Source nimble_official

README

nmostr

Library for working with Nostr.

Contained modules: * Events * Messages * Bech32 * Proof of work

Stability: Early days. Functional.

Usage

Compile with -d:ssl for wss:// connections
Example uses guzba's whisky i.e. nimble install whisky

import pkg/[nmostr, whisky]

let keypair = random Keypair
echo "New secret key: " & keypair.seckey.toBech32
echo "The public key: " & keypair.pubkey.toBech32

# Post a note
let socket = newWebSocket("wss://nostr.bongbong.com") # Remember to build with -d:ssl
socket.send CMEvent(event: note(keypair, "Hello world from nmostr!")).toJson
let response = socket.receiveMessage().get.data
echo response

# Read the note back
unpack fromMessage(response), msg:
  when msg is SMOk:
    socket.send CMRequest(id: randomID(), filter: Filter(ids: @[msg.id.hex])).toJson
    echo socket.receiveMessage().get.data

For more, see the reference client niomo and tests.

What is Nostr?

Nostr is a simple decentralized protocol. It defines a standard for sending and receiving messages between users identified by their public keys using generic servers or "relays" that handle storage and logic.

Its popularity grew with the goal of creating a decentralized alternative to Twitter and an alternative to the Fediverse (Mastodon/Pleroma) that doesn't constrain users to one server that can be shut down or blocked.


GitHub CI Minimum supported Nim version License