# BigChainDB Introduction ## Introduction BigchainDB is a scalable blockchain database. That is, it’s a “big data” database with some blockchain characteristics added, including decentralization, immutability and native support for assets. * decentralization (去中心化) Every node has its own locally-stored list of the public keys of other consortium members: the so-called keyring. There’s no centrally-stored or centrally-shared keyring. * immutability (不變性) unchanging over time or unable to be changed. For example, the decimal digits of π are immutable (3.14159…). * native support for assets (原生支持 assets) good for storing asset registrations and transfers. * Creation transactions and transfer transactions * With transactions metadata * An asset can have zero, one, or several owners * M to N transaction * Prevents double-spending ## Create a BigChainDB Transaction **Install bigchaindb-driver :** ```$ sudo pip3 install bigchaindb-driver``` **Create a python file :** ```python from bigchaindb_driver import BigchainDB from bigchaindb_driver.crypto import generate_keypair bdb = BigchainDB( 'https://test.ipdb.io', headers={'app_id': 'd9181966', 'app_key': '248d1c9b2b5e74e3921c05b676d00480'}) alice = generate_keypair() tx = bdb.transactions.prepare( operation = 'CREATE', signers = alice.public_key, asset = {'data': {'message': 'TEST'}}) signed_tx = bdb.transactions.fulfill( tx, private_keys = alice.private_key) returned_creation_tx = bdb.transactions.send(signed_tx) print("Success - " + str(returned_creation_tx)) ``` **Execute & Output :** ``` Success - {'metadata': None, 'inputs': [{'fulfills': None, 'fulfillment': 'pGSAIDmomxGkdpIiCmgu5tUCyeZSKbE3ZV0izNrHWN-u_ZYYgUAMB4YUSuJUEgT5g8HAytsNbOK3QkRRpmnCx7Lv54MwmzYMScccv3czu_1bMqOTs8aDKn5fvhbmtUiJkg9GIJoB', 'owners_before': ['4t5MZgMSRDz4qFd3Zv7YVJpBJGU5bEWGtdc5bGiat9M9']}], 'operation': 'CREATE', 'id': 'e61e1d83ad4de011f6e4e091c042b787567cf6759ac09879cb7ce8eee3f1d2d6', 'outputs': [{'amount': '1', 'condition': {'uri': 'ni:///sha-256;qNBDiSF_bu4egxkLGrKI5MS--p7fgezu9YpRzBE4qNY?fpt=ed25519-sha-256&cost=131072', 'details': {'type': 'ed25519-sha-256', 'public_key': '4t5MZgMSRDz4qFd3Zv7YVJpBJGU5bEWGtdc5bGiat9M9'}}, 'public_keys': ['4t5MZgMSRDz4qFd3Zv7YVJpBJGU5bEWGtdc5bGiat9M9']}], 'asset': {'data': {'message': 'TEST'}}, 'version': '1.0'} ``` [Check out your transaction on IPDB](https://test.ipdb.io/api/v1/transactions/e61e1d83ad4de011f6e4e091c042b787567cf6759ac09879cb7ce8eee3f1d2d6) ## Search by asset message : **code seaction:** ``` from bigchaindb_driver import BigchainDB from bigchaindb_driver.crypto import generate_keypair bdb = BigchainDB( 'https://test.ipdb.io', headers={'app_id': 'd9181966', 'app_key': '248d1c9b2b5e74e3921c05b676d00480'}) result = bdb.assets.get(search='yillkid') print ("Success - " + str(result)) ``` **Output:** ``` python3 search.py Success - [{'data': {'message': 'yillkid-2017-10-24-21-11'}, 'id': '961d8754008bf753c65ab1964bd161b208cda6d8e42753507d51e1ecea264fd2'}, {'data': {'message': 'yillkid-2017-10-24-21-40'}, 'id': '5cd1f9770ffbf55f823acb4aee72390e74bd6f96f734781ca04f4aa440ef46e0'}] ``` ## Reference * [Send your first transaction](https://www.bigchaindb.com/getstarted/) * [IPDB](https://developers.ipdb.io) * [Python API](https://docs.bigchaindb.com/projects/py-driver/en/latest/)