Inspiration
from nostr import Key, Event, Content, ContentKind
Generate your own key pair
your_key = Key.generate()
The key of the user you want to follow
user_key = Key.from_base64("your-base64-encoded-key")
Create the FOLLOW event
event = Event.follow(user_key.get_id(), content=None, key=your_key)
Post the event to the Nostr network
response = event.post()
if response.status_code == 200: print("Successfully followed user.") else: print(f"Error following user: {response.text}")
What it does
from nostr import Key, Event, Content, ContentKind
Create the FILTER event
event = Event.filter(f"@{user_key.get_id()}")
Post the event to the Nostr network
response = event.post()
if response.status_code == 200: print("Successfully created a filter.") else: print(f"Error creating a filter: {response.text}")
How I built it
Creating a Nostr client involves interacting with the Nostr network through its APIs. Nostr provides a set of REST APIs for querying events, retrieving relates events, and sending new events. Here is a simple step-by-step guide to creating a Nostr client:
Understand Nostr concepts:
Nostr is a decentralized, scalable, and flexible relay system. It enables the creation of relay applications and protocols by allowing anyone to post, subscribe, and fetch messages from a relay.
Set up a development environment:
To start developing a Nostr client, you'll need a suitable development environment. This can be your local machine, a virtual machine, or a cloud-based environment. Make sure to install the necessary libraries and dependencies.
Learn about Nostr APIs:
Nostr provides a set of REST APIs for interacting with the network. These APIs include:
/relay: Posts an event to the relay. /relay/{event-hash}: Fetches a single event by its hash. /relay/{event-hash}/related: Retrieves related events to a specific event. /subscribe: Subscribes to updates from the relay. Choose a programming language:
Nostr supports multiple programming languages, such as Python, JavaScript, Go, and Rust. Choose the language that best suits your needs and experience.
Write the client code:
Start by writing the client code, which should include functions for sending and receiving events. Use the Nostr APIs to interact with the network and retrieve the necessary data.
Test the client:
Once you've written the client code, it's essential to test it thoroughly. Test the client by sending and receiving events and making sure the client can interact with the Nostr network correctly.
Document the client:
Thoroughly document the client, including its purpose, functionality, and usage instructions. This will make it easier for others to understand and use the client.
Challenges I ran into
Accomplishments that I'm proud of
Relays are like the backend servers for Nostr. They allow Nostr clients to send them messages, and they may (or may not) store those messages and broadcast those messages to all other connected clients.
What I learned
If all the relays that you have used in the past go offline, all your posts will be unretrievable. This is one reason that Nostr allows users to connect to many relays – this ensures some degree of backup. That said, if you're really interested in being uncensorable, you can run your own personal relay.
What's next for Blockas
Built With
- adapters
- add
- application
- authentication
- auto-closing
- auto-grouping
- blacklist
- caching
- client-side
- contacts'
- data
- dead
- dexie)
- discovery
- drop-in
- encryption
- explicit
- following
- handlers
- implicit
- in-memory
- indexd
- is
- key
- list
- localstorage
- lud06
- lud16
- machines
- management
- nip-01
- nip-04:
- nip-07
- nip-18:
- nip-26
- nip-41:
- nip-46
- nip-57:
- nip-65)
- nip-65:
- nip-89:
- nip-90:
- nostr-tools/simplepool
- outbox-model
- permission
- private
- pubkey
- queries
- redis
- relay
- relays
- replacement
- repost
- server-side
- signing
- subscription
- subscriptions
- support
- t
- tag
- tokens
- usage
- vending
- won't
- zaps
Log in or sign up for Devpost to join the conversation.