Skip to main content
Join the chat at https://gitter.im/planetmint/planetmint-driver https://badge.fury.io/py/planetmint-driver.svg https://app.travis-ci.com/planetmint/planetmint-driver.svg?branch=main https://img.shields.io/codecov/c/github/planetmint/planetmint-driver/master.svg

Planetmint Python Driver

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):

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:

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.

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

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.

# 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

Credits

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

Metadata

Release files for planetmint-driver 0.18.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for planetmint-driver 0.18.5
File Size Uploaded Provenance
planetmint_driver-0.18.5.tar.gz 27.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for planetmint-driver 0.18.5
File Interpreter ABI Platform
planetmint_driver-0.18.5-py3-none-any.whl Python 3 none any Details

Total release size: 58.0 kB

Release files / planetmint_driver-0.18.5.tar.gz

Download URL planetmint_driver-0.18.5.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c1696d9acc0ee924f0aeb38b23d1b3f6203c3362f07fddc09817fe3182da8a32
BLAKE2b-256 checksum
How to use checksums
a4e776579ffc16d602dc7c48c0edd12129582207c3771cd103b872d33eec4667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure

Release files / planetmint_driver-0.18.5-py3-none-any.whl

Download URL planetmint_driver-0.18.5-py3-none-any.whl
Size 30.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
756a0a3e807bc29f11bbb6022a7137a1b7607619c0928f65ede04e4df49538cc
BLAKE2b-256 checksum
How to use checksums
57d4fffeddeaff9dcef8b560614a9c36dc0fd912e1c3d1954a23d927aae60950
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.9.21 Linux/6.8.0-1021-azure

Security for planetmint-driver 0.18.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page