Official Python driver for BigchainDB
Clone or download
ttmc Added another step to RELEASE_PROCESS.md
because readthedocs.org has gotten even more arcane.
Latest commit 5f2aa32 Nov 10, 2018
Permalink
Failed to load latest commit information.
.ci Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
.github Add BigchainDB server version Feb 13, 2018
bigchaindb_driver Prepare for the release of version 0.6.2 (#493) Nov 3, 2018
compose Problem: Tendermint settings are now in shell command (#413) May 8, 2018
docs Fixed 'Handcrafting Transactions' & 'Quickstart' docs (#489) Oct 21, 2018
media Problem: everyone has a nice image but we don't have it (#438) Jun 4, 2018
tests Problem: The send function is deprecated (#483) Sep 20, 2018
.coveragerc Problem: common code is not tested (#452) Jun 19, 2018
.editorconfig Add boilerplate Aug 12, 2016
.gitignore Problem: codecov setup not transparent (#451). Jun 19, 2018
.pre-commit-config.yaml Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
.travis.yml Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
AUTHORS.rst Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
CHANGELOG.rst Prepare for the release of version 0.6.2 (#493) Nov 3, 2018
CODE_OF_CONDUCT.md Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
CONTRIBUTING.rst Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
LICENSE Problem: no license shown in Github (#406) Apr 19, 2018
LICENSES.md Change docs license to CC-BY-4 (#462) Aug 2, 2018
MANIFEST.in Add docs on installing latest master with pip Nov 29, 2016
Makefile Problem: the updated Makefile is not mentioned in the docs (#428) May 18, 2018
README.rst Prepare for the release of version 0.6.2 (#493) Nov 3, 2018
RELEASE_PROCESS.md Added another step to RELEASE_PROCESS.md Nov 9, 2018
codecov.yml Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
docker-compose.yml Problem: No comments re/ licensing in source files (#465) Aug 10, 2018
pytest.ini Hardcode node keypair for testing purposes Feb 6, 2017
requirements_dev.txt Updates (#85) Sep 29, 2016
setup.py Prepare for the release of version 0.6.2 (#493) Nov 3, 2018
tox.ini Problem: tests are sometimes failing because a transaction is not yet… ( Apr 5, 2018
travis_pypi_setup.py Problem: No comments re/ licensing in source files (#465) Aug 10, 2018

README.rst

media/repo-banner@2x.png

Join the chat at https://gitter.im/bigchaindb/bigchaindb-driver 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.