planetmint-driver


Nameplanetmint-driver JSON
Version 0.18.4 PyPI version JSON
download
home_page
SummaryPython driver for Planetmint
upload_time2023-07-11 11:22:32
maintainer
docs_urlNone
authorYour Name
requires_python>=3.9,<4.0
licenseAGPLv3-or-later
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. Copyright Planetmint GmbH and Planetmint contributors
   SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
   Code is Apache-2.0 and docs are CC-BY-4.0

.. image:: https://badges.gitter.im/planetmint/planetmint-driver.svg
   :alt: Join the chat at https://gitter.im/planetmint/planetmint-driver
   :target: https://gitter.im/planetmint/planetmint-driver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge


.. image:: https://badge.fury.io/py/planetmint-driver.svg
    :target: https://badge.fury.io/py/planetmint-driver

.. image:: https://app.travis-ci.com/planetmint/planetmint-driver.svg?branch=main
    :target: https://app.travis-ci.com/planetmint/planetmint-driver

.. image:: https://img.shields.io/codecov/c/github/planetmint/planetmint-driver/master.svg
    :target: https://codecov.io/github/planetmint/planetmint-driver?branch=master


Planetmint Python Driver
==========================

* Free software: AGPLv3
* Check our `Documentation`_

.. contents:: Table of Contents


Features
--------

* Support for preparing, fulfilling, and sending transactions to a Planetmint
  node.
* Retrieval of transactions by id.

Install
----------

The instructions below were tested on Ubuntu 16.04 LTS. They should also work on other Linux distributions and on macOS. The driver might work on Windows as well, but we do not guarantee it. We recommend to set up (e.g. via Docker on Windows) an Ubuntu VM there.

We recommend you use a virtual environment to install and update to the latest stable version using `pip` (or `pip3`):

.. code-block:: text

    pip install -U planetmint-driver

That will install the latest *stable* Planetmint Python Driver. If you want to install an Alpha, Beta or RC version of the Python Driver, use something like:

.. code-block:: text

    pip install -U planetmint_driver==0.11.1

The above command will install version 0.11.1. You can find a list of all versions in `the release history page on PyPI <https://pypi.org/project/planetmint-driver/#history>`_.

More information on how to install the driver can be found in the `Quickstart`_

Planetmint Documentation
------------------------------------
* `Planetmint Server Quickstart`_
* `The Hitchhiker's Guide to Planetmint`_
* `HTTP API Reference`_
* `All Planetmint Documentation`_

Usage
----------
Example: Create a divisible asset for Alice who issues 10 token to Bob so that he can use her Game Boy.
Afterwards Bob spends 3 of these tokens.

If you want to send a transaction you need to `Determine the Planetmint Root URL`_.

.. code-block:: python

    # import Planetmint and create an object
    from planetmint_driver import Planetmint
    bdb_root_url = 'https://example.com:9984'
    bdb = Planetmint(bdb_root_url)

    # generate a keypair
    from planetmint_driver.crypto import generate_keypair
    alice, bob = generate_keypair(), generate_keypair()

    # create a digital asset for Alice
    game_boy_token = {
        'data': {
            'token_for': {
                'game_boy': {
                    'serial_number': 'LR35902'
                }
            },
            'description': 'Time share token. Each token equals one hour of usage.',
        },
    }

    # prepare the transaction with the digital asset and issue 10 tokens for Bob
    prepared_token_tx = bdb.transactions.prepare(
        operation='CREATE',
        signers=alice.public_key,
        recipients=[([bob.public_key], 10)],
        asset=game_boy_token)

    # fulfill and send the transaction
    fulfilled_token_tx = bdb.transactions.fulfill(
        prepared_token_tx,
        private_keys=alice.private_key)
    bdb.transactions.send_commit(fulfilled_token_tx)

    # Use the tokens
    # create the output and inout for the transaction
    transfer_asset = {'id': fulfilled_token_tx['id']}
    output_index = 0
    output = fulfilled_token_tx['outputs'][output_index]
    transfer_input = {'fulfillment': output['condition']['details'],
                      'fulfills': {'output_index': output_index,
                                   'transaction_id': transfer_asset['id']},
                      'owners_before': output['public_keys']}

    # prepare the transaction and use 3 tokens
    prepared_transfer_tx = bdb.transactions.prepare(
        operation='TRANSFER',
        asset=transfer_asset,
        inputs=transfer_input,
        recipients=[([alice.public_key], 3), ([bob.public_key], 7)])

    # fulfill and send the transaction
    fulfilled_transfer_tx = bdb.transactions.fulfill(
        prepared_transfer_tx,
        private_keys=bob.private_key)
    sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)

Compatibility Matrix
--------------------

+-----------------------+---------------------------+
| **Planetmint Server** | **Planetmint Driver**     |
+=======================+===========================+
| ``>= 2.0.0b7``        | ``0.6.2``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b7``        | ``0.6.1``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b7``        | ``0.6.0``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b5``        | ``0.5.3``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b5``        | ``0.5.2``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b5``        | ``0.5.1``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b1``        | ``0.5.0``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0a3``        | ``0.5.0a4``               |
+-----------------------+---------------------------+
| ``>= 2.0.0a2``        | ``0.5.0a2``               |
+-----------------------+---------------------------+
| ``>= 2.0.0a1``        | ``0.5.0a1``               |
+-----------------------+---------------------------+
| ``>= 1.0.0``          | ``0.4.x``                 |
+-----------------------+---------------------------+
| ``== 1.0.0rc1``       | ``0.3.x``                 |
+-----------------------+---------------------------+
| ``>= 0.9.1``          | ``0.2.x``                 |
+-----------------------+---------------------------+
| ``>= 0.8.2``          | ``>= 0.1.3``              |
+-----------------------+---------------------------+

`Although we do our best to keep the master branches in sync, there may be
occasional delays.`

License
--------
* `licenses`_ - open source & open content

Credits
-------

This package was initially created using Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. Many Planetmint developers have contributed since then.

.. _Documentation: https://docs.planetmint.com/projects/py-driver/
.. _pypi history: https://pypi.org/project/planetmint-driver/#history
.. _Quickstart: https://docs.planetmint.com/projects/py-driver/en/latest/quickstart.html
.. _Planetmint Server Quickstart: https://docs.planetmint.com/projects/server/en/latest/quickstart.html
.. _The Hitchhiker's Guide to Planetmint: https://www.planetmint.com/developers/guide/
.. _HTTP API Reference: https://docs.planetmint.com/projects/server/en/latest/http-client-server-api.html
.. _All Planetmint Documentation: https://docs.planetmint.com/
.. _Determine the Planetmint Root URL: https://docs.planetmint.com/projects/py-driver/en/latest/connect.html
.. _licenses: https://github.com/planetmint/planetmint-driver/blob/master/LICENSES.md
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "planetmint-driver",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/5b/e2168db341303cf04f0f12a588964c5a7a9ece0708aa3c929b785dbd9b34/planetmint_driver-0.18.4.tar.gz",
    "platform": null,
    "description": "\n.. Copyright Planetmint GmbH and Planetmint contributors\n   SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n   Code is Apache-2.0 and docs are CC-BY-4.0\n\n.. image:: https://badges.gitter.im/planetmint/planetmint-driver.svg\n   :alt: Join the chat at https://gitter.im/planetmint/planetmint-driver\n   :target: https://gitter.im/planetmint/planetmint-driver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\n\n\n.. image:: https://badge.fury.io/py/planetmint-driver.svg\n    :target: https://badge.fury.io/py/planetmint-driver\n\n.. image:: https://app.travis-ci.com/planetmint/planetmint-driver.svg?branch=main\n    :target: https://app.travis-ci.com/planetmint/planetmint-driver\n\n.. image:: https://img.shields.io/codecov/c/github/planetmint/planetmint-driver/master.svg\n    :target: https://codecov.io/github/planetmint/planetmint-driver?branch=master\n\n\nPlanetmint Python Driver\n==========================\n\n* Free software: AGPLv3\n* Check our `Documentation`_\n\n.. contents:: Table of Contents\n\n\nFeatures\n--------\n\n* Support for preparing, fulfilling, and sending transactions to a Planetmint\n  node.\n* Retrieval of transactions by id.\n\nInstall\n----------\n\nThe instructions below were tested on Ubuntu 16.04 LTS. They should also work on other Linux distributions and on macOS. The driver might work on Windows as well, but we do not guarantee it. We recommend to set up (e.g. via Docker on Windows) an Ubuntu VM there.\n\nWe recommend you use a virtual environment to install and update to the latest stable version using `pip` (or `pip3`):\n\n.. code-block:: text\n\n    pip install -U planetmint-driver\n\nThat will install the latest *stable* Planetmint Python Driver. If you want to install an Alpha, Beta or RC version of the Python Driver, use something like:\n\n.. code-block:: text\n\n    pip install -U planetmint_driver==0.11.1\n\nThe above command will install version 0.11.1. You can find a list of all versions in `the release history page on PyPI <https://pypi.org/project/planetmint-driver/#history>`_.\n\nMore information on how to install the driver can be found in the `Quickstart`_\n\nPlanetmint Documentation\n------------------------------------\n* `Planetmint Server Quickstart`_\n* `The Hitchhiker's Guide to Planetmint`_\n* `HTTP API Reference`_\n* `All Planetmint Documentation`_\n\nUsage\n----------\nExample: Create a divisible asset for Alice who issues 10 token to Bob so that he can use her Game Boy.\nAfterwards Bob spends 3 of these tokens.\n\nIf you want to send a transaction you need to `Determine the Planetmint Root URL`_.\n\n.. code-block:: python\n\n    # import Planetmint and create an object\n    from planetmint_driver import Planetmint\n    bdb_root_url = 'https://example.com:9984'\n    bdb = Planetmint(bdb_root_url)\n\n    # generate a keypair\n    from planetmint_driver.crypto import generate_keypair\n    alice, bob = generate_keypair(), generate_keypair()\n\n    # create a digital asset for Alice\n    game_boy_token = {\n        'data': {\n            'token_for': {\n                'game_boy': {\n                    'serial_number': 'LR35902'\n                }\n            },\n            'description': 'Time share token. Each token equals one hour of usage.',\n        },\n    }\n\n    # prepare the transaction with the digital asset and issue 10 tokens for Bob\n    prepared_token_tx = bdb.transactions.prepare(\n        operation='CREATE',\n        signers=alice.public_key,\n        recipients=[([bob.public_key], 10)],\n        asset=game_boy_token)\n\n    # fulfill and send the transaction\n    fulfilled_token_tx = bdb.transactions.fulfill(\n        prepared_token_tx,\n        private_keys=alice.private_key)\n    bdb.transactions.send_commit(fulfilled_token_tx)\n\n    # Use the tokens\n    # create the output and inout for the transaction\n    transfer_asset = {'id': fulfilled_token_tx['id']}\n    output_index = 0\n    output = fulfilled_token_tx['outputs'][output_index]\n    transfer_input = {'fulfillment': output['condition']['details'],\n                      'fulfills': {'output_index': output_index,\n                                   'transaction_id': transfer_asset['id']},\n                      'owners_before': output['public_keys']}\n\n    # prepare the transaction and use 3 tokens\n    prepared_transfer_tx = bdb.transactions.prepare(\n        operation='TRANSFER',\n        asset=transfer_asset,\n        inputs=transfer_input,\n        recipients=[([alice.public_key], 3), ([bob.public_key], 7)])\n\n    # fulfill and send the transaction\n    fulfilled_transfer_tx = bdb.transactions.fulfill(\n        prepared_transfer_tx,\n        private_keys=bob.private_key)\n    sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)\n\nCompatibility Matrix\n--------------------\n\n+-----------------------+---------------------------+\n| **Planetmint Server** | **Planetmint Driver**     |\n+=======================+===========================+\n| ``>= 2.0.0b7``        | ``0.6.2``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0b7``        | ``0.6.1``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0b7``        | ``0.6.0``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0b5``        | ``0.5.3``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0b5``        | ``0.5.2``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0b5``        | ``0.5.1``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0b1``        | ``0.5.0``                 |\n+-----------------------+---------------------------+\n| ``>= 2.0.0a3``        | ``0.5.0a4``               |\n+-----------------------+---------------------------+\n| ``>= 2.0.0a2``        | ``0.5.0a2``               |\n+-----------------------+---------------------------+\n| ``>= 2.0.0a1``        | ``0.5.0a1``               |\n+-----------------------+---------------------------+\n| ``>= 1.0.0``          | ``0.4.x``                 |\n+-----------------------+---------------------------+\n| ``== 1.0.0rc1``       | ``0.3.x``                 |\n+-----------------------+---------------------------+\n| ``>= 0.9.1``          | ``0.2.x``                 |\n+-----------------------+---------------------------+\n| ``>= 0.8.2``          | ``>= 0.1.3``              |\n+-----------------------+---------------------------+\n\n`Although we do our best to keep the master branches in sync, there may be\noccasional delays.`\n\nLicense\n--------\n* `licenses`_ - open source & open content\n\nCredits\n-------\n\nThis package was initially created using Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. Many Planetmint developers have contributed since then.\n\n.. _Documentation: https://docs.planetmint.com/projects/py-driver/\n.. _pypi history: https://pypi.org/project/planetmint-driver/#history\n.. _Quickstart: https://docs.planetmint.com/projects/py-driver/en/latest/quickstart.html\n.. _Planetmint Server Quickstart: https://docs.planetmint.com/projects/server/en/latest/quickstart.html\n.. _The Hitchhiker's Guide to Planetmint: https://www.planetmint.com/developers/guide/\n.. _HTTP API Reference: https://docs.planetmint.com/projects/server/en/latest/http-client-server-api.html\n.. _All Planetmint Documentation: https://docs.planetmint.com/\n.. _Determine the Planetmint Root URL: https://docs.planetmint.com/projects/py-driver/en/latest/connect.html\n.. _licenses: https://github.com/planetmint/planetmint-driver/blob/master/LICENSES.md\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n",
    "bugtrack_url": null,
    "license": "AGPLv3-or-later",
    "summary": "Python driver for Planetmint",
    "version": "0.18.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d25795763c45f615de5a2eeaf189c766fdf561c7c8136f01ebd0d2951ff8d1b",
                "md5": "c912fd1e39a5733dceaefde81730219d",
                "sha256": "3e88284028513b3a92aac49e612e742f6c94d67a66ba6dd4912bd1db442d53f3"
            },
            "downloads": -1,
            "filename": "planetmint_driver-0.18.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c912fd1e39a5733dceaefde81730219d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 30133,
            "upload_time": "2023-07-11T11:22:31",
            "upload_time_iso_8601": "2023-07-11T11:22:31.318575Z",
            "url": "https://files.pythonhosted.org/packages/9d/25/795763c45f615de5a2eeaf189c766fdf561c7c8136f01ebd0d2951ff8d1b/planetmint_driver-0.18.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c5be2168db341303cf04f0f12a588964c5a7a9ece0708aa3c929b785dbd9b34",
                "md5": "a028a726ef2ba8ba64b7edee68a313cb",
                "sha256": "5e34cbb68dc5c1bd831fe02ee24d1fcfac172bafd01f88cb3b33ee1c2ed0f1d9"
            },
            "downloads": -1,
            "filename": "planetmint_driver-0.18.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a028a726ef2ba8ba64b7edee68a313cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 27713,
            "upload_time": "2023-07-11T11:22:32",
            "upload_time_iso_8601": "2023-07-11T11:22:32.533501Z",
            "url": "https://files.pythonhosted.org/packages/7c/5b/e2168db341303cf04f0f12a588964c5a7a9ece0708aa3c929b785dbd9b34/planetmint_driver-0.18.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 11:22:32",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "planetmint-driver"
}
        
Elapsed time: 0.15677s