Skip to main content

Getting users into nostr, fastr. A basic nostr `Client` class built in the nbdev (fast) framework to get people started nostr.

Project description

nostrfastr

What is this?

  • This package attempts to be a well documented and tested instance of a very basic client framework in nostr that can help others understand nostr quickly or get started sending messages in minutes.
  • Contained is a collection of tools built on top of this basic Client class showing some potential uses of nostr any how quickly we can build on it in python.
    • A “sentinel” node that serves as a barebones client to rebroadcast user data across additional nostr relays. While this is a relatively simple concept I haven’t seen much discussion around the potential benefits and implications.
    • notifyr - a decorator that will alert on success or failure of any decorated function via nostr DM
    • a vanity address generator decorated with the notifyr function so you can leave it running and get notified when it finishes

Why nbdev?

This library uses the nbdev framework to aggregate some useful tools from python-nostr into a more structured client class that could serve as the basis for other python tools. nbdev is great because it allows for relatively easy development of code in-line with readable and explanatory documentation. This webpage is a rendering of the same notebooks that are exported to form the package code. If you clone the Github repository you can view and run the code you see in the documentation. It will almost certainly not be the most perfomant way to implement much of what I am doing here, but I hope it can make the nostr protocol more accessible to a wider audience.

Install

pip install nostrfastr

or alternatively, clone the github repositor and refer to this guide to get started working in nbdev.

How to use

from nostrfastr.client import Client

Connect and perform an operation…

with Client(relay_urls=['wss://relay.damus.io']) as client:
    print('Are we connected?')
    print('\t', client.relay_manager.connection_statuses)
print('Are we connected?')
print('\t', client.relay_manager.connection_statuses)
Are we connected?
     {'wss://relay.damus.io': True}
Are we connected?
     {'wss://relay.damus.io': False}

And use the client to build something useful with nostr - like a bot that notifies you of your python processing status on long code runs

from nostrfastr.notifyr import notifyr
@notifyr
def raise_error():
    raise Exception('Oh no! Process failed!')

@notifyr
def success():
    return 1+1

Or generate an vanity address and have it notify you at another nostr address when it’s done

from nostrfastr.vanity import vanity_notifyr

vanity_notifyr(startswith='23', style='npub')
/Users/ryanarmstrong/python/nostrfastr/nostrfastr/client.py:479: UserWarning: the current implementation of messages should be used with caution
                    see https://github.com/nostr-protocol/nips/issues/107
  warnings.warn('''the current implementation of messages should be used with caution

PrivateKey(npub123kyc...nwdqt768zj)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nostrfastr-0.0.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

nostrfastr-0.0.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file nostrfastr-0.0.1.tar.gz.

File metadata

  • Download URL: nostrfastr-0.0.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for nostrfastr-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5341061f70d97aee40d5ef9bf01f5680b18f83122cd86b3d3f4f6efbfca07b2b
MD5 5218c7c4d40cd67291bd63d5db2e08ae
BLAKE2b-256 a33adb6aa8ed008a7ff3efedda4c22af50f362ff3aa92eda538d2d525d38e14c

See more details on using hashes here.

File details

Details for the file nostrfastr-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: nostrfastr-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for nostrfastr-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dcab2405f88bc9824fd51d70cb683030a8586a1f37aa5e2f88e5499a9326e69d
MD5 5f2ea5c63b5657ca1bf157dcab728fca
BLAKE2b-256 50d676f63448131d7bad02fcb5b6c89a8358bc88f6a315c698fd5ee8c230487f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page