Skip to main content
media/repo-banner@2x.png Join the chat at https://gitter.im/bigchaindb/bigchaindb-driver https://img.shields.io/pypi/v/bigchaindb-driver.svg https://img.shields.io/travis/bigchaindb/bigchaindb-driver/master.svg https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb-driver/master.svg Documentation Status

BigchainDB Python Driver

  • Free software: Apache Software License 2.0

  • Check our Documentation

Features

  • Support for preparing, fulfilling, and sending transactions to a BigchainDB 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 bigchaindb-driver

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

pip install -U bigchaindb_driver==0.5.0a4

The above command will install version 0.5.0a4 (Alpha 4). 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

BigchainDB 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 BigchainDB Root URL.

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

# generate a keypair
from bigchaindb_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

BigchainDB Server

BigchainDB 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 BigchainDB developers have contributed since then.

Changelog

0.6.2 (2018-11-03)

Changed

  • In setup.py, changed python-rapidjson==0.6.0 to ~=0.6.0, and changed requests>=2.11.0 to >=2.20.0

0.6.1 (2018-10-21)

Fixed

  • Fixed the problem with a docs page (Handcrafting Transactions) that wouldn’t build.

0.6.0 (2018-10-20)

Changed

  • Added support for deterministic keypair generation from a 32-byte seed. See pull request #487 by external contributor @excerebrose

  • Pinned cryptoconditions==0.8.0 in setup.py

Removed

  • The send() function was removed. See pull request #483.

Known issues

  • Builds of the Handcrafting Transactions page started failing again, in Travis CI and on ReadTheDocs.

0.5.3 (2018-09-12)

Changed

  • Fixed a failing unit test

  • Pinned cryptoconditions==0.7.2 in setup.py

  • Fixed the Handcrafting Transactions page in the docs

0.5.2 (2018-08-31)

Added

  • Cap exponential backoff depending on timeout value for reasonable waiting time in event of network recovery. #470 <https://github.com/bigchaindb/bigchaindb-driver/pull/470>

  • Update cryptoconditions dependency because of security vulnerability CVE-2018-10903. #472 <https://github.com/bigchaindb/bigchaindb-driver/pull/472>

0.5.1 (2018-08-23)

Added

  • Support for BigchainDB server v2.0.0.b5.

  • added round-robin strategy to connect to nodes of the BigchainDB network BEP 14

0.5.0 (2018-06-14)

Added

  • Added three new methods to send/post a transaction as discussed here:

    • send_commit

    • send_async

    • send_sync

Deprecated

  • send() under TransactionEndpoint, and available via BigchainDB.transactions. Replaced by the above three methods: send_commit(), send_async(), and send_sync().

0.5.0a4 (2018-05-07)

0.5.0a2 (2018-04-18)

0.5.0a1 (2018-04-03)

There were many changes between BigchainDB 1.3 and BigchainDB 2.0 Alpha, too many to list here. We wrote a series of blog posts to summarize most changes, especially those that affect end users and application developers:

0.4.1 (2017-08-02)

Fixed

0.4.0 (2017-07-05)

Added

  • Support for BigchainDB server (HTTP API) 1.0.0.

0.3.0 (2017-06-23)

Added

  • Support for BigchainDB server (HTTP API) 1.0.0rc1.

  • Support for crypto-conditions RFC draft version 02.

  • Added support for text search endpoint /assets?search=

0.2.0 (2017-02-06)

Added

  • Support for BigchainDB server 0.9.

  • Methods for GET / and GET /api/v1

Changed

  • Node URLs, passed to BigchainDB() MUST not include the api prefix '/api/v1', e.g.:

    • BEFORE: http://localhost:9984/api/v1

    • NOW: http://localhost:9984

0.1.0 (2016-11-29)

Added

  • Support for BigchainDB server 0.8.0.

  • Support for divisible assets.

Removed

  • create() and transfer() under TransactionEndpoint, and available via BigchainDB.transactions. Replaced by the three “canonical” transaction operations: prepare(), fulfill(), and send().

  • Support for client side timestamps.

0.0.3 (2016-11-25)

Added

  • Support for “canonical” transaction operations:

    • prepare

    • fulfill

    • send

Deprecated

  • create() and transfer() under TransactionEndpoint, and available via BigchainDB.transactions. Replaced by the above three “canonical” transaction operations: prepare(), fulfill(), and send().

Fixed

  • BigchainDB() default node setting on its transport class. See commit 0a80206

0.0.2 (2016-10-28)

Added

  • Support for BigchainDB server 0.7.0

0.0.1dev1 (2016-08-25)

  • Development (pre-alpha) release on PyPI.

Added

  • Minimal support for POST (via create() and transfer()), and GET operations on the /transactions endpoint.

0.0.1a1 (2016-08-12)

  • Planning release on PyPI.

Release files for bigchaindb-driver 0.6.2

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

Source distribution (sdist)

Source distribution for bigchaindb-driver 0.6.2
File Size Uploaded
bigchaindb_driver-0.6.2.tar.gz 511.5 kB Details

Release files / bigchaindb_driver-0.6.2.tar.gz

Download URL bigchaindb_driver-0.6.2.tar.gz
Size 511.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f9652012c085e71b4550a4ec284ab65b5ff4397c131a9ec12b5ad27e7af51f3d
BLAKE2b-256 checksum
How to use checksums
b8bb7f32dcc7758c22271c7d4dbfc1619be5950d08ca6e63a05a3c8bdd5de3e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.6.2 This release

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.0

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1a1

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