Skip to main content

A simple python Data Vending Machine (DVM) implementation on nostr

Project description

ezdvm

Easily run any python code behind a DVM on Nostr. Just pick a kind (for basic text-to-text use 5050) and put the code you want to run in the do_work() function. Then run the DVM.

Install from pip

pip install ezdvm

Install from local repo for development on ezdvm

git clone https://github.com/dtdannen/ezdvm.git
cd ezdvm/
python3.12 -m venv venv
source venv/bin/activate
pip install -e .

Create your own DVM

Steps:

  1. Choose the job request kind in the init function
  2. Run any python code inside the do_work() function. The event arg is the original job request from the user, in the form of nostr-sdk event, for python examples see here: https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-sdk-ffi/bindings-python/examples
from ezdvm import EZDVM


class HelloWorldDVM(EZDVM):

    def __init__(self):
        # choose the job request kinds you will listen and respond to
        super().__init__(kinds=[5050])

    async def do_work(self, event):
        return "Hello World!"


if __name__ == "__main__":
    hello_world_dvm = HelloWorldDVM()
    hello_world_dvm.add_relay("wss://relay.damus.io")
    hello_world_dvm.add_relay("wss://relay.primal.net")
    hello_world_dvm.add_relay("wss://nos.lol")
    hello_world_dvm.add_relay("wss://nostr-pub.wellorder.net")
    hello_world_dvm.start()

Testing

Once it's running on your machine, if you are using kind 5050 you can test it here: https://dvmdash.live/playground/

Note that currently you have to use a NIP-07 extension to login first

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

ezdvm-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezdvm-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ezdvm-0.1.2.tar.gz.

File metadata

  • Download URL: ezdvm-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ezdvm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 703cfbf12e660f6dc209e31b3f56dcd5c8bf07569800c7d73cf36d7e6170974f
MD5 7df309aad805723d4e842feb42df6961
BLAKE2b-256 107423d245706b3ca2cf042424c5ba3dc35d829a6c470fa66026a99b510f2655

See more details on using hashes here.

File details

Details for the file ezdvm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ezdvm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ezdvm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8fb5302bb5fe03c3aa1ca7697b39b00e041522037c3332e3adff74bd91425cd5
MD5 9f0b1af420d9d5d87aa4db50bf03151d
BLAKE2b-256 d334717c7e4afe0a42545e70db8084eb4a18f8fd212c01d5ba2370339a48333a

See more details on using hashes here.

Supported by

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