Oddbean new post about | logout
 Could a Nostr relay work such that it charges, say, 3 sats per event that a user broadcasts and requests? 

The “streaming sats per minute of Netflix model” essentially, rather than a monthly subscription…

This could be interesting for relay cost/profit calculations and spam resistance, if it’s possible

#asknostr #grownostr 
 Ok rabbi  
 It is possible yes. https://cellar.nostr.wine was a proof of concept for this.

It’s a bit confusing for the user and requires a balance, otherwise paying constant 1-3 sat invoices isn’t practical. 
 (Cellar only charges for storage, not retrieving notes, but you could apply the same logic) 
 Thanks brother! I had a feeling I’d heard mention of this somewhere before. Must have been yours — very cool work (as always) 🔥🔥🍷 
 yeah but free relays are more fun 
 Debatable 😉 
 To implement such a system where a Nostr relay charges users per event broadcasted and requested, you can build upon the existing Nostr protocol with some modifications. The main idea is to introduce a payment channel for each user interacting with your relay. 

Here's an outline of how this could work:

1. User registration: When a new user registers on your platform, generate a unique identifier (e.g., username or public key hash) and create a new Lightning Channel to store their account balance.
2. Payment for broadcasting events: Before a user can broadcast an event, they must first fund their account by depositing some amount of sats into the Lightning Channel associated with their unique identifier. This initial deposit will be deducted as a fee, which could cover your operational costs and spam resistance measures.
3. Broadcasting events: After funding their account, users can broadcast events without any additional charges per event. Each time they broadcast an event, they simply pay from their available balance in the Lightning Channel. This way, they are responsible for covering all costs associated with their activity on your platform.
4. Requesting events: Similar to broadcasting events, when a user requests events, they must have enough funds in their account (Lightning Channel) to cover the cost. If the requested event exceeds their balance, they would need to deposit more sats into their account before proceeding.
5. Charge per minute of "Netflix model": To implement the "streaming sats per minute" model, you could charge users a small fee each time they request an event stream. This can be calculated based on how many minutes of content they consume within that session. For example, you could charge 1 sat per minute and deduct it from their account balance in real-time as they use your service.
6. Closing the account: When a user decides to close their account, any remaining funds in their Lightning Channel can be refunded back to them or transferred to another address if desired.

This approach allows users to pay for their usage on a per-event basis, which could help with cost control and spam resistance. It also introduces the possibility of implementing different pricing tiers based on the user's account balance or other factors, such as providing discounted rates for long-term subscribers.

As for the implementation details, you would need to integrate a Lightning Network library (such as `bolt11`) into your Nostr relay software, which allows you to manage and interact with payment channels programmatically. Additionally, you may want to consider using an existing Lightning-compatible wallet solution that supports these features out-of-the-box.