Skip to content

Websocket Test Client

Melvin Carvalho edited this page May 7, 2023 · 3 revisions

Welcome to the WebSocket Test Client for Nostr wiki page! This guide will help you understand how to use the WebSocket Test Client Chrome Extension to interact with Nostr relays and events.

The WebSocket Test Client is a useful tool for developers and users who wish to test and explore the Nostr network. It enables users to establish WebSocket connections to Nostr relays, send and receive messages, and inspect events in real-time.

Installation

  1. To install the WebSocket Test Client Chrome Extension, visit the Chrome Web Store and click on "Add to Chrome".
  2. Once installed, you can access the extension by clicking on its icon in the Chrome browser's toolbar.

Using WebSocket Test Client with Nostr

Connecting to a Nostr Relay

  1. Open the WebSocket Test Client extension.
  2. In the URL field, enter the WebSocket address of the Nostr relay you want to connect to (e.g., ws://your-nostr-relay.example.com).
  3. Click the "Connect" button to establish a WebSocket connection.

Subscribing to Nostr Events

  1. After connecting to a Nostr relay, you can send subscription requests to receive specific types of events.
  2. In the "Message" section, select "Text" and enter a subscription request in JSON format, for example:
["REQ", "your_subscription_id", {"types": [0, 1]}]

Replace your_subscription_id with a unique identifier for your subscription.

  1. Click the "Send" button to send the subscription request.

Receiving Nostr Events

  1. Once subscribed, you'll start receiving Nostr events that match your subscription request.
  2. Incoming messages will appear in the "Received messages" section, where you can inspect the event data and details.

Publishing Nostr Events

  1. To publish a Nostr event, create a JSON-formatted message representing the event, for example:
{
  "content": "hello world",
  "created_at": 1683438945,
  "id": "302944bc70fecbfefc88907a46d276d47c6446e7b34085f66318eee27a4577ca",
  "kind": 1,
  "pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
  "sig": "f4756eb315fcad23613726c1bca3f328c763dd1d1031bb200f037441afc70e06a95d0c945f3064340d0d445c0c285373cc018dfb31c30ed784a4d884c9277e0b",
  "tags": []
}

Replace the placeholder values with the actual event data. Additionally NAK can be used to generate test events.

  1. In the "Message" section, select "Text" and enter the JSON-formatted message.
  2. Click the "Send" button to publish the event.

Disconnecting from a Nostr Relay

  1. When you're finished testing, click the "Disconnect" button to close the WebSocket connection.

Conclusion

The WebSocket Test Client Chrome Extension is a valuable tool for exploring the Nostr network, testing relays, and inspecting events. We hope this guide has been helpful in demonstrating how to use the extension for Nostr-related purposes. If you have any questions or suggestions, feel free to reach out to the Nostr community or open an issue on the project's GitHub repository. Happy exploring!

Clone this wiki locally