Skip to main content

Implementation of the client and protocols of the Pletyvo decentralized platform in Python

Project description

[!WARNING] This is an unstable version. Changes may be backwards incompatible

py-pletyvo

Typed, async‑first Python client for the Pletyvo decentralized platform and it's protocols (Python ≥ 3.9)

Install

pip install -U pletyvo

Usage

Engine

To begin using the client, you need to create an engine — the core component responsible for all communication with the Pletyvo gateway. You can create one using http.HTTPDefault:

from pletyvo.client import http

engine: http.abc.HTTPClient = http.HTTPDefault(
    config=http.Config(
        url="http://testnet.pletyvo.osyah.com",
        network="AAEAAAAB",
    ),
)

The http.Config accepts:

  • url: The gateway endpoint.
  • network | None: the network identifier encoded as a base64 string. By default, has an already set network on the node side

Service

A service is a high-level interface that aggregates protocol-specific HTTP services. This top-level object internally composes http.DAppService & http.DeliveryService. The service requires a signer — an object responsible for producing cryptographic signatures over event bodies. The signer must implement the dapp.abc.Signer interface.

from pletyvo.client import http

service = http.HTTPService.di(
    engine=engine,
    signer=signer,
)

Want full control?

You can instantiate each service manually by passing required dependencies.

from pletyvo.client import http

service = http.HTTPService(
    dapp=http.DAppService(
        hash=http.HashService(...),
        event=http.EventService(...),
    ),
    delivery=http.DeliveryService(
        channel=http.ChannelService(...),
        post=http.PostService(...),
        message=http.MessageService(...),
    )
)

Dependency graph

---
config:
  layout: elk
---
flowchart LR

  subgraph Dependencies
    dapp.abc.Signer["dapp.abc.Signer"]
    http.HTTPClient["http.HTTPClient"]
  end

  subgraph Services
    http.HashService["http.HashService"]
    http.EventService["http.EventService"]
    http.ChannelService["http.ChannelService"]
    http.PostService["http.PostService"]
    http.MessageService["http.MessageService"]
    http.DAppService["http.DAppService"]
    http.DeliveryService["http.DeliveryService"]
    http.HTTPService["http.HTTPService"]
  end

  dapp.abc.Signer --> http.ChannelService & http.PostService & http.MessageService
  http.HTTPClient --> http.HashService & http.EventService & http.ChannelService & http.PostService & http.MessageService

  http.EventService --> http.ChannelService & http.PostService & http.DAppService
  http.HashService --> http.DAppService

  http.ChannelService --> http.DeliveryService
  http.PostService --> http.DeliveryService
  http.MessageService --> http.DeliveryService

  http.DAppService --> http.HTTPService
  http.DeliveryService --> http.HTTPService

dApp

Platform docs: dApp

The dApp protocol defines how signed events are created, verified, and published on the Pletyvo network. Each dapp.Event consists of dapp.EventBody and a corresponding signature, both of which are required for persistence. You can create a dApp service using either the shorthand or manual constructor:

The dApp service itself does not construct or validate signatures — it only transmits fully-formed signed events.

from pletyvo.client import http

dapp_service = http.DAppService.di(
    engine=engine,
)
dapp_service = http.DAppService(
    hash=http.HashService(...),
    event=http.EventService(...),
)

Cryptography: signing with dapp.AuthHeader

Most dApp calls that create or update data must be signed with an ED25519 keypair; read‑only requests work without it.

py‑pletyvo lets you obtain a keypair from a random seed, raw bytes, or a file. If you prefer BIP‑39 mnemonics, generate a seed with an external helper such as osyah/homin and load it into the signer.

from pletyvo.protocol import dapp

signer: dapp.abc.Signer

signer = dapp.ED25519.gen()
signer = dapp.ED25519.from_file(...)
signer = dapp.ED25519(...)

Pletyvo: decentralized applications (UA)

Delivery

Platform docs: Delivery

The delivery layer exposes three narrow services — http.ChannelService, http.PostService, and http.MessageService — bundled under http.DeliveryService.

from pletyvo.client import http

delivery_service = http.DeliveryService.di(
    engine=engine,
    signer=signer,
    event=event_service,
)
delivery_service = http.DeliveryService(
    channel=http.ChannelService(...),
    post=http.PostService(...),
    message=http.MessageService(...),
)

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

pletyvo-0.0.0a6.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

pletyvo-0.0.0a6-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file pletyvo-0.0.0a6.tar.gz.

File metadata

  • Download URL: pletyvo-0.0.0a6.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for pletyvo-0.0.0a6.tar.gz
Algorithm Hash digest
SHA256 2ae1a5a738fd3620c7ac27a0d5656da3919316a466fa69dccf9a60873f8c7b22
MD5 b6aedd9986c085aaf4cf4fe6a0b56e77
BLAKE2b-256 b44b61fdd2361bf8d86dfffd3326072366a07b198d9662f03511503f7836ab38

See more details on using hashes here.

File details

Details for the file pletyvo-0.0.0a6-py3-none-any.whl.

File metadata

  • Download URL: pletyvo-0.0.0a6-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for pletyvo-0.0.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 13d20ce889fde659838223846f16e4a73507f62581c9aab6cbeb2ad27a7c6c4b
MD5 313cd74635596f97f14042c9ccbc7856
BLAKE2b-256 65f33da15c1655e189117cefa84d091d7d7af97eaa8b19625c96a0b38fe064b8

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