Skip to main content

Python package to access Universa API from python.

Project description

Universa

Build status PyPI Downloads Latest PyPI version License

This is an under-construction official Python package from Universa to facilitate access to the Java library using Universa's UMI protocol.

Installation

Installation

pip install universa

Usage

Prerequisites

You need to have UMI installed somewhere on your system. To run, UMI requires JVM v1.8.* (or never) to be installed, too.

UMI can be used in one of three modes:

  • pipe – the UMI instance is dynamically executed in a subprocess, and a pipe is used for communication.
  • tcp – connect to an already running UMI instance via TCP socket.
  • unix – connect to an already running UMI instance via Unix socket.

By default it expects an umi binary to be installed an reachable via the shell $PATH, and will invoke it automatically in pipe mode. Use universa.transport.setupUMI method if you need to switch the connection method to some other.

Example

#!/usr/bin/env python3
from universa.transport import transport
from universa.types import PrivateKey, Contract, RevokePermission

if __name__ == '__main__':
    # The next line is not necessary if umi is reachable via the $PATH
    # transport.setupUMI('pipe', '/usr/local/bin/umi')

    # To connect to an already running UMI instance you may use one of this modes:
    # transport.setupUMI('tcp', host='127.0.0.1', port=12345)  # IPv6 is also ok
    # transport.setupUMI('unix', path='/path-to-the-socket')

    print(transport.version)

    private_key = PrivateKey(size=2048)
    contract = Contract()
    short_address = private_key.public_key.short_address
    owner_role = contract.set_owner_addresses(short_address)
    revoke_permission = RevokePermission(owner_role)
    contract.add_permission(revoke_permission)

Docs and resources

For more information see:

License

This package is available as open source under the terms of the MIT License.

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

universa-0.1.1.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distributions

universa-0.1.1-py3-none-any.whl (19.6 kB view hashes)

Uploaded Python 3

universa-0.1.1-py2-none-any.whl (19.6 kB view hashes)

Uploaded Python 2

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