brh28 / nostr-service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nostr-service

NodeJS library for interacting with Nostr.

Getting started

  1. Inititialize the Service with your private key.
const nostr = new NostrService({ nostrPrivKey: <your_priv_key> })
console.log(`Nostr PublicKey = ${nostr.publicKey()}`)
  1. Connect to relays with comma sperated list of URLs
nostr.connect(["wss://relay.damus.io", "wss://relay.nostr.info"])
  .then(() => console.log(`Connected Relays: ${JSON.stringify(nostr.connectedRelays())})`)

Note, reference registry for info about active relays

  1. Publish event by defining kind, content and tags:
nostr.publishEvent({
 kind: 1,
 tags: [],
 content: `This is a basic text note`,
})

About

License:MIT License


Languages

Language:JavaScript 100.0%