Exploring the Nostr Protocol:
Building a Usable Client MVP
The objective of this project was to gain a deeper understanding of the Nostr protocol at a technical level by implementing it in a practical application.
What is Nostr?
Nostr, which stands for "Notes and Other Stuff Transmitted by Relays," is a networking protocol that has gained popularity in the Bitcoin community. It uses the same cryptographic methods as Bitcoin to manage identities, specifically employing public/private key encryption. Nostr also follows the same development practices with its Nostr Improvement Protocols (NIPs) that, once approved, can be implemented by clients and relays. The first NIP defines an event, which can be sent to relays and to which clients can subscribe.
For more information about Nostr, visit: https://github.com/nostr-protocol/nostr
The Project: Building a Usable Client MVP
Unsatisfied with the existing clients, I aimed to create a minimum viable product (MVP) for a more user-friendly Nostr client.
User Story and Features
The primary user story was simple: as a user, I want to be able to read all messages from a specific set of people. To achieve this, I needed to implement the following features:
- Connect to a relay
- Read and filter messages, either on the relay or locally
- Read quoted messages and display them in a visually appealing manner
- Provide basic configuration options for identities
I began by visiting https://www.nostr.directory/ to find some identities to read in my client. Then, I searched for public implementations to learn the technical aspects from existing code. I found https://github.com/nbd-wtf/nostr-tools#readme , a simple and effective package that abstracts some lower-level details.
Nostr employs WebSockets, a relatively new protocol for creating connections between a browser and a server. I had previous experience with WebSockets while building software to update firmware on trams, so I felt comfortable working with the protocol. It's great to see WebSockets being used, as they are incredibly simple and efficient.
After choosing nostr-tools as the foundation for my client, I began loading messages from relays. This process was straightforward, requiring only some sorting. Next, I added a playground page to explore different event types and quotes, restructured the methods for loading events, and designed an appealing front-end.
Finally, I included a configuration component and some documentation. Most of my time was spent working with Tailwind CSS and structuring Svelte components.
The source code can be found on the Redsummit GitHub repository here: https://github.com/sebastianbartmann/redsummit/pull/1/files
You can test the current version here: https://redsummit.dev/nostr-client
As a developer, I find these times to be extraordinary. The Bitcoin and wider crypto communities are brimming with creative energy, and tools like Nostr are prime examples of this innovation. Building software has become much more accessible, but widespread digitalization requires active participation from every member of society. The Bitcoin community has fostered pockets of people who are rethinking old norms, as exemplified in this lovely video: https://www.youtube.com/watch?v=MWmfDSxtvi0