src/nmostr

Search:
Group by:

Nim library for the Nostr protocol - nmostr.

Posting and retrieving an event

Example uses 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

Exports

toHex, EventID, verify, random, $, toBytes, article, toHex, hexToRaw, bytes, bytesLen, sign, dumpHook, parseHook, init, bytes, SecretKey, updateID, fromBytes, toBytes, toHex, fromBytes, rawToHex, SchnorrSignature, init, fromHex, $, toSecretKey, readHexChar, Event, fromHex, rawToHex, fromBytes, stamp, parseHook, fromHex, bytes, fromHex, dumpHook, populateRaw, populate, dumpHook, getParameterizedID, hexToRaw, Metadata, serialize, signSchnorr, toPublicKey, random, toBytes, note, bytesLen, init, verify, dumpHook, fromHex, bytesLen, sign, signSchnorr, toKeypair, toHex, init, getParameterizedID, init, parseHook, Keypair, sysRng, PublicKey, populateHex, metadata, fromHex, toString, parseHook, toString, toHex, random, toBytes, article, toHex, hexToRaw, bytes, sysRng, bytesLen, sign, parseHook, dumpHook, init, verify, bytes, SecretKey, updateID, fromBytes, toBytes, parseHook, toHex, fromBytes, EventID, fromHex, toSecretKey, rawToHex, serialize, $, Event, parseHook, fromHex, fromBytes, stamp, fromHex, bytes, rawToHex, Filter, populateRaw, populate, getParameterizedID, hexToRaw, toString, Metadata, signSchnorr, dumpHook, toPublicKey, random, toBytes, note, bytesLen, init, $, fromHex, bytesLen, readHexChar, parseHook, sign, signSchnorr, toKeypair, toHex, dumpHook, dumpHook, init, getParameterizedID, init, verify, SchnorrSignature, PublicKey, populateHex, metadata, fromHex, fromHex, toString, dumpHook, init, matches, Keypair, parseHook, random, article, rawToHex, dumpHook, SMAuth, bytesLen, parseHook, dumpHook, parseHook, bytes, $, updateID, toSecretKey, parseHook, CMAuth, stamp, CMCount, dumpHook, dumpHook, populateRaw, populate, CMClose, hexToRaw, dumpHook, dumpHook, dumpHook, toBytes, init, parseHook, dumpObjectAsArray, parseHook, fromHex, dumpHook, bytesLen, readHexChar, signSchnorr, $, toHex, dumpHook, dumpHook, init, parseHook, hexToRaw, rawToHex, dumpHook, fromMessage, populateHex, SMOk, fromHex, dumpHook, toString, init, parseHook, dumpHook, Keypair, Message, UnknownMessageError, toString, parseHook, parseHook, verify, toHex, toBytes, parseHook, toHex, bytes, sign, init, Filter, parseHook, SecretKey, parseHook, dumpHook, toBytes, toHex, fromBytes, fromHex, serialize, Event, fromHex, fromBytes, parseHook, fromHex, bytes, getParameterizedID, Metadata, signSchnorr, toPublicKey, random, parseHook, note, bytesLen, SMEose, parseHook, EventID, SMCount, sign, parseArrayAsObject, toKeypair, fromBytes, SMNotice, dumpHook, SMEvent, getParameterizedID, CMRequest, dumpHook, init, parseHook, verify, SchnorrSignature, ServerMessage, sysRng, dumpHook, PublicKey, ClientMessage, metadata, CMEvent, fromHex, matches, parseHook, randomID, toFilter, toHex, random, toBytes, NRelay, article, verifyChecksum, toFilter, toHex, hexToRaw, toBech32, bytes, sysRng, bytesLen, sign, encode, parseHook, dumpHook, toString, init, fromBech32, toFilter, verify, toBech32, bytes, decode, fromBytes, SecretKey, NNote, updateID, toFilter, fromBytes, toBytes, parseHook, toHex, fromBytes, encode, EventID, fromHex, toFilter, fromBytes, Bech32Entity, toSecretKey, rawToHex, serialize, $, decode, Event, parseHook, fromHex, fromBytes, toBech32, stamp, fromHex, toFilter, bytes, rawToHex, NAddr, populateRaw, fromBytes, populate, toBech32, getParameterizedID, hexToRaw, toString, NEvent, Metadata, signSchnorr, dumpHook, toPublicKey, random, toBytes, CharsetSet, note, toBech32, bytesLen, toBech32, init, toBech32, fromBech32, $, fromHex, bytesLen, readHexChar, parseHook, sign, signSchnorr, toBech32, toBech32, toKeypair, toHex, dumpHook, init, getParameterizedID, init, fromBech32, fromBytes, verify, fromWords, SchnorrSignature, PublicKey, populateHex, metadata, Charset, fromHex, fromHex, fromNostrBech32, toString, toFilter, uint5, dumpHook, init, toWords, fromBech32, fromBech32, fromBytes, Keypair, NProfile, NostrTLV, fromBech32, fromBech32