• Stars
    star
    104
  • Rank 330,515 (Top 7 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Official Python driver for BigchainDB

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.

More Repositories

1

bigchaindb

Meet BigchainDB. The blockchain database.
Python
4,024
star
2

js-bigchaindb-driver

Official BigchainDB JavaScript driver for Node.js and the browser
JavaScript
216
star
3

cryptoconditions

A Python implementation of the Crypto-Conditions spec
Python
72
star
4

org

High-level planning for BigchainDB and allied projects
71
star
5

privacy-protocols

Ideas on how to share private data on a public blockchain
Python
68
star
6

bigchaindb-examples

[deprecated] Examples and tutorials for BigchainDB use cases.
JavaScript
48
star
7

kyber

OLD & NOT SUPPORTED BigchainDB examples, tutorials & burning experiments
Python
47
star
8

js-driver-orm

A CRAB-based ORM for BigchainDB
JavaScript
40
star
9

BEPs

BigchainDB Enhancement Proposals
Shell
33
star
10

java-bigchaindb-driver

Official Java and Android driver for BigchainDB
Java
28
star
11

bigchaindb-hyperledger

BigchainDB integration with HyperLedger Fabric. In collaboration with TheLedger
TypeScript
25
star
12

js-bigchaindb-graphql

A GraphQL interface for BigchainDB in JavaScript
JavaScript
18
star
13

whitepaper

The old, out-of date, BigchainDB whitepaper. Do not read unless you want to be confused.
TeX
15
star
14

py-ipld

Python implementation of the IPLD specification.
Python
14
star
15

dashboard

A react app showing BigchainDB transactions as a dynamic timeline view.
JavaScript
12
star
16

tutorial-crab

A tutorial for Creating, Retrieving, Appending and Burning assets on BigchainDB
CSS
12
star
17

bdb-transaction-cli

Old/deprecated command line tool to create and sign transactions for BigchainDB
Python
11
star
18

go-bigchaindb-driver

Official Go BigchainDB driver
Go
11
star
19

project-jannowitz

Specs and usage examples from projects done by the BigchainDB Consulting team.
JavaScript
10
star
20

ilp-plugin-bigchaindb

ILP ledger plugin for BigchainDB
JavaScript
9
star
21

bigchaindb-smart-assets

Consensus plugin for making assets more "smart"
Python
8
star
22

hyperchaindb

BigchainDB meets Hyperledger hackathon
Go
8
star
23

graphql-bigchaindb

A GraphQL API for BigchainDB
Python
8
star
24

benchmark

Command line tool to send random transactions to BigchainDB
Python
7
star
25

site

🦁 The fabulous cat of blockchain websites
CSS
7
star
26

js-reactor

Minimalistic boilerplate to power your next React app
JavaScript
7
star
27

github-projects

πŸ€– Microservice to cache and expose our GitHub projects. Beep boop.
JavaScript
7
star
28

ethereum-integration

Implementation of BEP-15.
JavaScript
6
star
29

game-ecosystem-simulation

Ecosystem simulation game using blockchain / digital twin / asset tracking
TypeScript
6
star
30

example-data-wallet

Simple wallet for data(streams) in React + Redux
JavaScript
5
star
31

js-bigchaindb-wallet

A suite of tools to write wallets that interact with BigChainDB
TypeScript
5
star
32

multi-ledger-integrations

BigchainDB transaction integrations with other ledgers using a workflow based architecture
JavaScript
5
star
33

coalaip-http-api

An HTTP wrapper for COALA IP
Python
5
star
34

js-utility-belt

Opinionated collection of JavaScript nice-to-haves
JavaScript
5
star
35

bigchaindb-common

[deprecated] Set of reusable Python components for BigchainDB
Python
4
star
36

android-boilerplate

Boilerplate App for Android using BigchainDB Java Driver
Java
4
star
37

energycert

TypeScript
4
star
38

car-example

Code for a blog post about using MongoDB directly
Python
4
star
39

bigchaindb-react-redux-boilerplate

BigchainDB + React + Redux boilerplate
JavaScript
4
star
40

bigchaindb-node-ansible

Quick and dirty ansible playbook for bigchaindb node deployment on ubuntu 18.04 without containers.
Python
4
star
41

bigchaindb-jukebox

A pay-as-you-stream platform
JavaScript
4
star
42

bigchaindb-react-webpack-boilerplate

Boilerplate for BigchainDB + React
JavaScript
4
star
43

python-rapidjson-schema

Python extension for rapidjson schema validation
C++
3
star
44

python-driver-orm

Orm implementation of official python driver
3
star
45

multipipes

Create and scale complex pipelines on multiple cores
Python
3
star
46

bigchaindb-hs

BigchainDB client tools in Haskell
Haskell
3
star
47

bigchaindb-examples-asset-search

Search assets on BigchainDB
JavaScript
3
star
48

events-plugin-example

A simple plugin that prints new blocks on the console
Python
3
star
49

nginx_3scale

An OpenResty NGINX configuration with 3scale integration
Lua
2
star
50

bigchaindb-shared

Precompiled client side tools for BigchainDB with various language frontends
Python
2
star
51

pytest-bigchaindb

A BigchainDB plugin for pytest.
Python
2
star
52

meetups

πŸ€– Microservice to cache and expose our upcoming Meetups. Beep boop.
JavaScript
2
star
53

pytest-rethinkdb

A RethinkDB plugin for pytest.
Python
2
star
54

IoT-hackfest-berlin-2017

Code for the IoT+ BigchainDb + MSFT + VW PoC at the hackfest in Berlin held from 28 Feb to 03 Mar 2017
Python
2
star
55

stylelint-config-bigchaindb

πŸ’… For consistent CSS across BigchainDB, IPDB, Ocean Protocol & ascribe's repos.
JavaScript
2
star
56

DBH17

Dutch Blockchain Hackathon '17
Python
1
star
57

java-crypto-conditions

Java implementation of condition variation and fulfillment
Java
1
star
58

supply-claim

Hackathon ScanTrust, Xtech, Innogy and BigchainDB
Python
1
star
59

bigchaindb-wallet

Bigchaindb wallet sketch
Python
1
star
60

js-cryptoconditions-utils

Utility functions for cryptoconditions
JavaScript
1
star
61

HoneyBadgerBFT

Honey Badger of BFT Protocols in Haskell
Haskell
1
star