nips icon indicating copy to clipboard operation
nips copied to clipboard

Developer docs?

Open Leichesters opened this issue 2 years ago • 7 comments

I wanted to build a project using Nostr but cant find docs for it. Having specifications is good but how do I start? Do you have a beginner friendly tutorial or some documentation?

For example here are some questions I have:

  • Where do I send the request?
  • How should I send it? In JSON?
  • Can I send it from everywhere? Even from my browser in the developer tools for example?

Thanks for your help

Leichesters avatar Feb 09 '23 18:02 Leichesters

  1. To the relay
  2. Most libraries don't require you to do all the JSON stuff manually, see python-nostr for example:
import json 
import ssl
import time
from nostr.event import Event
from nostr.relay_manager import RelayManager
from nostr.message_type import ClientMessageType
from nostr.key import PrivateKey

relay_manager = RelayManager()
relay_manager.add_relay("wss://nostr-pub.wellorder.net")
relay_manager.add_relay("wss://relay.damus.io")
relay_manager.open_connections({"cert_reqs": ssl.CERT_NONE}) # NOTE: This disables ssl certificate verification
time.sleep(1.25) # allow the connections to open

private_key = PrivateKey()

event = Event("Hello Nostr")
private_key.sign_event(event)

relay_manager.publish_event(event)
time.sleep(1) # allow the messages to send

relay_manager.close_connections()
  1. Yes, Nostr has some Javascript libraries avaliable

AveragePythonEnjoyer29 avatar Feb 09 '23 21:02 AveragePythonEnjoyer29

  • Where do I send the request?

requests are sent to relays via WebSocket, so we refer to them as a WebSocket URL, i.e var relay = new WebSocket('wss://relay.com')

  • How should I send it? In JSON?

a request is a stringified array, i.e. relay.send(JSON.stringify(['REQ','sub_id',{filter},{filter}]))

  • Can I send it from everywhere? Even from my browser in the developer tools for example?

yes

eskema avatar Feb 09 '23 21:02 eskema

This is a good place to start for building a web client: https://github.com/nbd-wtf/nostr-tools

Otherwise a lot of resources can be found here: https://github.com/aljazceru/awesome-nostr

wanacode avatar Feb 10 '23 00:02 wanacode

https://nips.nostr.com/1

fiatjaf avatar Feb 10 '23 00:02 fiatjaf

Hey thanks for your help. I was wondering how do you tell other servers about your data? Do you have to send it to multiple servers or will they forward it for you? Also is there a Javascript / Dart library available?

Leichesters avatar Feb 10 '23 10:02 Leichesters

Yes, send it to multiple servers.

To publish something, you write a post, sign it with your key and send it to multiple relays.

The original protocol description says relays don't talk to other relays, but I believe some relays do talk to each other now.

For libraries see https://github.com/aljazceru/awesome-nostr

wanacode avatar Feb 10 '23 14:02 wanacode

https://nostr.how/

fiatjaf avatar Feb 10 '23 14:02 fiatjaf

Hello, I am a Lightning Network enthusiast. I want to issue my own token on the store network and upload my own icon. How do I issue my own Token on the Lightning Network? What are the steps?

SirSteven1 avatar Feb 18 '24 03:02 SirSteven1