No description
Find a file
2023-12-06 14:44:57 -05:00
.github Merge pull request #7 from Gruruya/dependabot/github_actions/actions/deploy-pages-3 2023-12-06 14:44:57 -05:00
LICENSES Make reuse compliant 2023-09-13 13:23:28 -04:00
src Organize 2023-10-25 07:48:37 -04:00
tests Split tests into multiple files 2023-09-23 17:33:18 -04:00
.gitignore Make reuse compliant 2023-09-13 13:23:28 -04:00
CHANGELOG.md Remove redundant template abstraction 2023-09-29 00:08:32 -04:00
LICENSE.md Make reuse compliant 2023-09-13 13:23:28 -04:00
nmostr.nimble Release 0.1.1 2023-09-28 23:11:57 -04:00
README.md Split tests into multiple files 2023-09-23 17:33:18 -04:00

[
Copyright © 2023 Gruruya gruruya.chi4c@slmails.com
SPDX-License-Identifier: CC-BY-SA-4.0 ]:#

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