Skip to main content

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

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.DefaultEngine:

from pletyvo.client import http

engine: http.abc.Engine = http.DefaultEngine(
    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.Service.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.Service(
    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.DefaultEngine["http.DefaultEngine"]
  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.Service["http.Service"]
  end

  dapp.abc.Signer --> http.ChannelService & http.PostService & http.MessageService
  http.DefaultEngine --> 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.Service
  http.DeliveryService --> http.Service

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.0a7.tar.gz (15.7 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.0a7-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pletyvo-0.0.0a7.tar.gz
  • Upload date:
  • Size: 15.7 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.0a7.tar.gz
Algorithm Hash digest
SHA256 af3cc9e4ce16f4cb17595fc7d5f190387fe0f981d86a6259dbd2b1e7e2725a70
MD5 4a9c1e4f10d3886c309130f0b7f845d2
BLAKE2b-256 35bed9928d247a0651d58bcd6032c53edfc62802bfb3603b8c31de32c0eb496e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pletyvo-0.0.0a7-py3-none-any.whl
  • Upload date:
  • Size: 22.8 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.0a7-py3-none-any.whl
Algorithm Hash digest
SHA256 ad6f1354bcf2496f16caf8581141adf03d29c025f88b854903b43243bb759e8e
MD5 638314de54d3ed6ae8d9eec3770939b8
BLAKE2b-256 556051260ae4d69e211f7d9bef8c5238d8692aad7d3213c8222fc4a4f7636b3c

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