Skip to main content

Python client SDK for Oasis ROFL.

Project description

oasis-rofl-client

PyPI version

Python client SDK for Oasis ROFL.

Installation

pip install oasis-rofl-client

Or using uv:

uv add install oasis-rofl-client

The package requires Python 3.9+ and depends on httpx for async HTTP operations.

Quickstart

The RoflClient provides async methods for interacting with ROFL services:

import asyncio
from oasis_rofl_client import RoflClient

async def main():
    client = RoflClient()
    
    key = await client.generate_key("my-key-id")
    print(f"Generated SECP256K1 key: {key}")

asyncio.run(main())

API Reference

RoflClient

The main client class for interacting with ROFL runtime services.

Constructor

RoflClient(url: str = '')
  • url: Optional URL or Unix socket path
    • If empty (default): Uses Unix socket at /run/rofl-appd.sock
    • If starts with http:// or https://: Uses HTTP transport
    • Otherwise: Treats as Unix socket path

Methods

async get_app_id() -> str

Get app ID.

  • Returns: Bech32-encoded ROFL app ID
  • Raises: httpx.HTTPStatusError if the request fails
async generate_key(key_id: str, kind: KeyKind = KeyKind.SECP256K1) -> str

Fetches or generates a cryptographic key from ROFL.

  • Parameters:
    • key_id: Identifier for the key
    • kind: Type of key to generate (default: KeyKind.SECP256K1). Available options:
      • KeyKind.RAW_256: Generate 256 bits of entropy
      • KeyKind.RAW_384: Generate 384 bits of entropy
      • KeyKind.ED25519: Generate an Ed25519 private key
      • KeyKind.SECP256K1: Generate a Secp256k1 private key
  • Returns: The private key as a hex string
  • Raises: httpx.HTTPStatusError if the request fails
async sign_submit(tx: TxParams, encrypt: bool = False) -> dict[str, Any]

Sign the given Ethereum transaction with an endorsed ephemeral key and submit it to Sapphire.

Note: Transaction nonce and gas price are ignored.

  • Parameters:
    • tx: Transaction parameters
    • encrypt: End-to-end encrypt the transaction before submitting (default: False)
  • Returns: Deserialized response data object
  • Raises: httpx.HTTPStatusError if the request fails
  • Raises: cbor2.CBORDecodeValueError If the response data is invalid
async get_metadata() -> dict[str, str]

Get all user-set metadata key-value pairs.

  • Returns: Dictionary of metadata key-value pairs
  • Raises: httpx.HTTPStatusError if the request fails
async set_metadata(metadata: dict[str, str]) -> None

Set metadata key-value pairs.

This replaces all existing app-provided metadata. Will trigger a registration refresh if the metadata has changed.

  • Parameters:
    • metadata: Dictionary of metadata key-value pairs to set
  • Raises: httpx.HTTPStatusError if the request fails
async query(method: str, args: bytes) -> bytes

Query the on-chain paratime state.

  • Parameters:
    • method: The query method name
    • args: CBOR-encoded query arguments
  • Returns: CBOR-encoded response data
  • Raises: httpx.HTTPStatusError if the request fails

Examples

For a complete working example, see examples/basic_usage.py.

Release Process

Publishing to PyPI is fully automated via GitHub Actions.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details or visit http://www.apache.org/licenses/LICENSE-2.0.

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

oasis_rofl_client-0.1.7.tar.gz (176.1 kB view details)

Uploaded Source

Built Distribution

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

oasis_rofl_client-0.1.7-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file oasis_rofl_client-0.1.7.tar.gz.

File metadata

  • Download URL: oasis_rofl_client-0.1.7.tar.gz
  • Upload date:
  • Size: 176.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oasis_rofl_client-0.1.7.tar.gz
Algorithm Hash digest
SHA256 82d35f0ed1c05d1e0c36ceec90bd7834d6a5d628452026318a7985e6a2f8ee1b
MD5 e4538bf6b4d0b615013f9dbe6fc79371
BLAKE2b-256 523c0de36de1332f8b1b2b9ab35fc5c9a98df70656d8249d55ce709b523a5d70

See more details on using hashes here.

File details

Details for the file oasis_rofl_client-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: oasis_rofl_client-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oasis_rofl_client-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 61beb4a96a7708e1e15eea778ab4bc0eb77a549c1f019e3984dd25dface073ae
MD5 9e2df02af392b31e8b281417e48016c3
BLAKE2b-256 968221c81c893b68e92e3cdc78140bf413ed904c776f0c7fc2035874a5e1e60d

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