Skip to content

Publishing events

Create a signed event and call the method Nostr::Client#publish to send the event to the relay.

# Create a user with the keypair
user = keypair)

# Create a signed event
text_note_event = user.create_event(
  kind: Nostr::EventKind::TEXT_NOTE,
  content: 'Your feedback is appreciated, now pay $8'

# Connect asynchronously to a relay
relay = 'wss://', name: 'Wine')

# Listen asynchronously for the connect event
client.on :connect do
  # Send the event to the relay

The relay will verify the signature of the event with the public key. If the signature is valid, the relay should broadcast the event to all subscribers.