### Developer Setup: Clone Repository Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Clones the BigchainDB driver repository from GitHub for local development. ```bash git clone git@github.com:your_name_here/bigchaindb-driver.git cd bigchaindb-driver/ ``` -------------------------------- ### Developer Setup: Create Branch Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Creates a new Git branch for local development work on the BigchainDB driver. ```bash git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Start BigchainDB Server Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Starts the BigchainDB server and its dependencies (MongoDB, Tendermint) in detached mode using Docker Compose. ```bash docker-compose up -d bigchaindb ``` -------------------------------- ### Install BigchainDB Python Driver from Source Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/advanced-installation.rst Installs the BigchainDB Python Driver after obtaining the source code, by running the setup.py script. ```bash python setup.py install ``` -------------------------------- ### Access Documentation Build Environment Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/aboutthedocs.rst This snippet demonstrates how to start a bash session within the documentation build container. This allows for manual execution of build commands. ```bash docker-compose run --rm bdocs bash ``` -------------------------------- ### Install Specific Alpha/Beta/RC Version Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Installs a specific pre-release version (e.g., alpha) of the bigchaindb_driver package. ```bash pip3 install bigchaindb_driver==0.5.0a4 ``` -------------------------------- ### Connect to BigchainDB Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Demonstrates how to instantiate the BigchainDB driver, connecting to a specified node URL. It shows how to handle connections with and without authentication tokens. ```ipython from bigchaindb_driver import BigchainDB bdb_root_url = 'https://example.com:9984' # Use YOUR BigchainDB Root URL here bdb = BigchainDB(bdb_root_url) ``` ```ipython tokens = {'app_id': 'your_app_id', 'app_key': 'your_app_key'} bdb = BigchainDB(bdb_root_url, headers=tokens) ``` -------------------------------- ### Upgrade setuptools Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Upgrades the setuptools package using pip. ```bash pip install --upgrade setuptools OR pip3 install --upgrade setuptools ``` -------------------------------- ### Python Versioning Example Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/RELEASE_PROCESS.md Illustrates the Python Semantic Versioning scheme used by BigchainDB, including examples for final, alpha, and release candidate versions. ```python # Example versioning schemes: # 0.9.0 for a typical final release # 4.5.2a1 for the first Alpha release # 3.4.5rc2 for Release Candidate 2 ``` -------------------------------- ### Clone BigchainDB Python Driver Repository Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/advanced-installation.rst Clones the public Git repository for the BigchainDB Python Driver from GitHub. ```bash git clone git://github.com/bigchaindb/bigchaindb-driver ``` -------------------------------- ### Documentation Improvements Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/CHANGELOG.rst Lists fixes and improvements made to the project's documentation, including specific pages like 'Handcrafting Transactions' and the 'Quickstart guide'. ```APIDOC Documentation Fixes and Improvements: - Fixed a docs page ('Handcrafting Transactions') that wouldn't build (0.6.1). - Fixed the 'Handcrafting Transactions' page in the docs (0.5.3). - Fixed 'Handcrafting transactions' documentation (Pull request #312) (0.4.1). - Fixed Quickstart guide (Pull request #316) (0.4.1). ``` -------------------------------- ### BigchainDB Driver Usage Example Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/README.rst A Python code example demonstrating how to use the BigchainDB driver to create a divisible asset, issue tokens, and transfer them between users. It covers key generation, transaction preparation, fulfillment, and sending to the BigchainDB node. ```python from bigchaindb_driver import BigchainDB from bigchaindb_driver.crypto import generate_keypair bdb_root_url = 'https://example.com:9984' bdb = BigchainDB(bdb_root_url) 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) ``` -------------------------------- ### Install BigchainDB Python Driver Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/README.rst Instructions for installing the BigchainDB Python Driver using pip. It covers installing the latest stable version and pre-release versions. ```text pip install -U bigchaindb-driver ``` ```text pip install -U bigchaindb_driver==0.5.0a4 ``` -------------------------------- ### Install BigchainDB Driver with Development Dependencies Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/requirements_dev.txt This command installs the BigchainDB driver from a Git repository and includes development dependencies. It specifies exact versions for pip, bumpversion, and wheel. ```bash pip==21.1 bumpversion==0.5.3 wheel==0.29.0 git+https://github.com/bigchaindb/bigchaindb.git -e .[dev] ``` -------------------------------- ### Complete Handcrafted Transfer Transaction Example Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/handcraft.rst A comprehensive example demonstrating the creation of a BigchainDB transfer transaction from scratch. It includes key generation, asset definition, output configuration, input preparation, signing with ED25519, and transaction ID calculation. ```python import json import base58 import sha3 from cryptoconditions import Ed25519Sha256 from bigchaindb_driver.crypto import generate_keypair bob = generate_keypair() operation = 'TRANSFER' version = '2.0' asset = {'id': handcrafted_creation_tx['id']} metadata = None ed25519 = Ed25519Sha256(public_key=base58.b58decode(bob.public_key)) output = { 'amount': '1', 'condition': { 'details': { 'type': ed25519.TYPE_NAME, 'public_key': base58.b58encode(ed25519.public_key).decode(), }, 'uri': ed25519.condition_uri, }, 'public_keys': (bob.public_key,), } outputs = (output,) input_ = { 'fulfillment': None, 'fulfills': { 'transaction_id': handcrafted_creation_tx['id'], 'output_index': 0, }, 'owners_before': (alice.public_key,) } inputs = (input_,) handcrafted_transfer_tx = { 'asset': asset, 'metadata': metadata, 'operation': operation, 'outputs': outputs, 'inputs': inputs, 'version': version, 'id': None, } message = json.dumps( handcrafted_transfer_tx, sort_keys=True, separators=(',', ':'), ensure_ascii=False, ) message = sha3.sha3_256(message.encode()) message.update('{}{}'.format( handcrafted_transfer_tx['inputs'][0]['fulfills']['transaction_id'], handcrafted_transfer_tx['inputs'][0]['fulfills']['output_index']).encode() ) ed25519.sign(message.digest(), base58.b58decode(alice.private_key)) fulfillment_uri = ed25519.serialize_uri() handcrafted_transfer_tx['inputs'][0]['fulfillment'] = fulfillment_uri json_str_tx = json.dumps( handcrafted_transfer_tx, sort_keys=True, separators=(',', ':'), ensure_ascii=False, ) transfer_txid = sha3.sha3_256(json_str_tx.encode()).hexdigest() handcrafted_transfer_tx['id'] = transfer_txid ``` -------------------------------- ### Threshold Fulfillment Example Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/advanced-usage.rst Demonstrates how to create and validate a transaction with a threshold fulfillment, including adding subfulfillments and conditions, and performing validation checks. ```python threshold_fulfillment.add_subfulfillment(subfulfillment2) threshold_fulfillment.add_subcondition(subfulfillment3.condition) threshold_tx_transfer['inputs'][0]['fulfillment'] = threshold_fulfillment.serialize_uri() assert threshold_fulfillment.validate(threshold_tx_fulfillment_message) == True assert b.validate_fulfillments(threshold_tx_transfer) == True assert b.validate_transaction(threshold_tx_transfer) b.write_transaction(threshold_tx_transfer) threshold_tx_transfer ``` -------------------------------- ### Install BigchainDB Python Driver (Alternative) Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Installs the bigchaindb_driver package using pip, an alternative command to the one mentioned earlier. ```bash pip install bigchaindb_driver OR pip3 install bigchaindb_driver ``` -------------------------------- ### Prepare Transfer Transaction Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Prepares a transfer transaction, specifying the asset to transfer, the inputs, and the recipients. ```ipython In [0]: prepared_transfer_tx = bdb.transactions.prepare( ...: operation='TRANSFER', ...: asset=transfer_asset, ...: inputs=transfer_input, ...: recipients=bob.public_key, ...: ) ``` -------------------------------- ### BigchainDB API Reference Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Provides an overview of key BigchainDB driver API endpoints and their functionalities, including transaction creation, retrieval, and sending. ```APIDOC BigchainDB: __init__(url: str, headers: dict = None) Initializes the BigchainDB driver with the specified node URL and optional headers. get_transaction(tx_id: str) -> dict Retrieves a transaction by its ID. Parameters: tx_id: The ID of the transaction to retrieve. Returns: A dictionary representing the transaction. send_transaction(signed_tx: dict) -> dict Sends a signed transaction to the BigchainDB network. Parameters: signed_tx: A dictionary representing the signed transaction. Returns: A dictionary confirming the transaction submission. sign_transaction(transaction: dict, private_key: str) -> dict Signs a transaction with the provided private key. Parameters: transaction: The transaction dictionary to sign. private_key: The private key for signing. Returns: A dictionary representing the signed transaction. create_transaction(from_key: str, to_key: str, asset_id: str, operation: str, metadata: dict = None) -> dict Creates a transaction object (not signed or sent). Parameters: from_key: The public key of the sender. to_key: The public key of the recipient. asset_id: The ID of the asset being transferred. operation: The type of operation (e.g., 'CREATE', 'TRANSFER'). metadata: Optional metadata to include in the transaction. Returns: A dictionary representing the unsigned transaction. get_assets(search: str = None, owner: str = None) -> list Retrieves assets, optionally filtered by search query or owner. Parameters: search: A string to search for within asset metadata or payload. owner: The public key of the asset owner. Returns: A list of asset dictionaries. get_block(block_hash: str) -> dict Retrieves a block by its hash. Parameters: block_hash: The hash of the block to retrieve. Returns: A dictionary representing the block. get_blocks(limit: int = 100, offset: int = 0) -> list Retrieves a list of blocks. Parameters: limit: The maximum number of blocks to return. offset: The number of blocks to skip. Returns: A list of block dictionaries. get_status() -> dict Retrieves the status of the BigchainDB node. Returns: A dictionary containing node status information. get_keys() -> dict Retrieves public/private key pairs managed by the driver (if applicable). Returns: A dictionary of key pairs. get_outputs(public_key: str, unspent: bool = True) -> list Retrieves outputs associated with a public key, optionally filtered by unspent status. Parameters: public_key: The public key to query. unspent: Whether to retrieve only unspent outputs. Returns: A list of output dictionaries. get_inputs(tx_id: str, output_index: int) -> dict Retrieves information about a specific input fulfillment. Parameters: tx_id: The ID of the transaction containing the input. output_index: The index of the output that the input fulfills. Returns: A dictionary representing the input fulfillment. get_conditions(tx_id: str, output_index: int) -> dict Retrieves the conditions associated with a specific output. Parameters: tx_id: The ID of the transaction containing the output. output_index: The index of the output. Returns: A dictionary representing the output conditions. get_fulfillments(tx_id: str, output_index: int) -> dict Retrieves the fulfillment details for a specific output. Parameters: tx_id: The ID of the transaction containing the output. output_index: The index of the output. Returns: A dictionary representing the fulfillment details. get_metadata(tx_id: str) -> dict Retrieves the metadata associated with a transaction. Parameters: tx_id: The ID of the transaction. Returns: A dictionary containing the transaction's metadata. get_asset_by_metadata(metadata_key: str, metadata_value: str) -> list Retrieves assets based on metadata key-value pairs. Parameters: metadata_key: The key of the metadata field to search. metadata_value: The value of the metadata field to search for. Returns: A list of asset dictionaries matching the metadata criteria. get_transactions_by_asset(asset_id: str) -> list Retrieves all transactions related to a specific asset ID. Parameters: asset_id: The ID of the asset. Returns: A list of transaction dictionaries. get_transactions_by_operation(operation: str) -> list Retrieves transactions based on their operation type. Parameters: operation: The type of operation (e.g., 'CREATE', 'TRANSFER', 'DELETE'). Returns: A list of transaction dictionaries. get_transactions_by_public_key(public_key: str) -> list Retrieves all transactions associated with a given public key. Parameters: public_key: The public key to query. Returns: A list of transaction dictionaries. get_transactions_by_timestamp(start_time: int, end_time: int) -> list Retrieves transactions within a specified time range. Parameters: start_time: The start timestamp (Unix epoch time). end_time: The end timestamp (Unix epoch time). Returns: A list of transaction dictionaries. get_transactions_by_hash(tx_hash: str) -> list Retrieves transactions by their hash (note: typically tx_id is used). Parameters: tx_hash: The hash of the transaction. Returns: A list of transaction dictionaries matching the hash. get_block_by_timestamp(start_time: int, end_time: int) -> list Retrieves blocks within a specified time range. Parameters: start_time: The start timestamp (Unix epoch time). end_time: The end timestamp (Unix epoch time). Returns: A list of block dictionaries. get_block_by_height(height: int) -> dict Retrieves a block by its height. Parameters: height: The height of the block. Returns: A dictionary representing the block. get_block_by_tx_id(tx_id: str) -> dict Retrieves the block that contains a specific transaction. Parameters: tx_id: The ID of the transaction. Returns: A dictionary representing the block containing the transaction. get_block_by_public_key(public_key: str) -> list Retrieves blocks that contain transactions associated with a given public key. Parameters: public_key: The public key to query. Returns: A list of block dictionaries. get_block_by_asset_id(asset_id: str) -> dict Retrieves the block that contains the creation transaction of a specific asset. Parameters: asset_id: The ID of the asset. Returns: A dictionary representing the block. get_block_by_metadata(metadata_key: str, metadata_value: str) -> list Retrieves blocks that contain transactions with specific metadata. Parameters: metadata_key: The key of the metadata field to search. metadata_value: The value of the metadata field to search for. Returns: A list of block dictionaries matching the metadata criteria. get_block_by_operation(operation: str) -> list Retrieves blocks that contain transactions of a specific operation type. Parameters: operation: The type of operation (e.g., 'CREATE', 'TRANSFER', 'DELETE'). Returns: A list of block dictionaries. get_block_by_hash_prefix(hash_prefix: str) -> list Retrieves blocks whose hashes start with a given prefix. Parameters: hash_prefix: The prefix of the block hash to search for. Returns: A list of block dictionaries matching the hash prefix. get_block_by_tx_hash(tx_hash: str) -> dict Retrieves the block that contains a specific transaction hash. Parameters: tx_hash: The hash of the transaction. Returns: A dictionary representing the block containing the transaction. get_block_by_tx_metadata(tx_id: str, metadata_key: str, metadata_value: str) -> dict Retrieves the block containing a specific transaction that also has matching metadata. Parameters: tx_id: The ID of the transaction. metadata_key: The key of the metadata field to search. metadata_value: The value of the metadata field to search for. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_operation(tx_id: str, operation: str) -> dict Retrieves the block containing a specific transaction that also has a matching operation. Parameters: tx_id: The ID of the transaction. operation: The type of operation. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction associated with a public key. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_asset_id(tx_id: str, asset_id: str) -> dict Retrieves the block containing a specific transaction related to an asset ID. Parameters: tx_id: The ID of the transaction. asset_id: The ID of the asset. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_timestamp(tx_id: str, start_time: int, end_time: int) -> dict Retrieves the block containing a specific transaction within a timestamp range. Parameters: tx_id: The ID of the transaction. start_time: The start timestamp (Unix epoch time). end_time: The end timestamp (Unix epoch time). Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_hash_prefix(tx_id: str, hash_prefix: str) -> dict Retrieves the block containing a specific transaction whose hash starts with a prefix. Parameters: tx_id: The ID of the transaction. hash_prefix: The prefix of the transaction hash. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_condition(tx_id: str, condition_type: str) -> dict Retrieves the block containing a specific transaction with a matching condition type. Parameters: tx_id: The ID of the transaction. condition_type: The type of condition (e.g., 'fulfillment'). Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_fulfillment(tx_id: str, fulfillment_type: str) -> dict Retrieves the block containing a specific transaction with a matching fulfillment type. Parameters: tx_id: The ID of the transaction. fulfillment_type: The type of fulfillment (e.g., 'ed25519-sha256'). Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_output(tx_id: str, output_index: int) -> dict Retrieves the block containing a specific transaction's output. Parameters: tx_id: The ID of the transaction. output_index: The index of the output. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_input(tx_id: str, input_index: int) -> dict Retrieves the block containing a specific transaction's input. Parameters: tx_id: The ID of the transaction. input_index: The index of the input. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_signature(tx_id: str, signature: str) -> dict Retrieves the block containing a specific transaction with a matching signature. Parameters: tx_id: The ID of the transaction. signature: The signature of the transaction. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_input(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction where the public key is in an input. Parameters: tx_id: The ID of the transaction. public_key: The public key to check in the inputs. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction where the public key is in an output condition. Parameters: tx_id: The ID of the transaction. public_key: The public key to check in the output conditions. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_fulfillment(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction where the public key is in a fulfillment. Parameters: tx_id: The ID of the transaction. public_key: The public key to check in the fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_signature(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction where the public key is in a signature. Parameters: tx_id: The ID of the transaction. public_key: The public key to check in the signature. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_owner(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction where the public key is listed as an owner. Parameters: tx_id: The ID of the transaction. public_key: The public key to check as an owner. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_metadata(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction where the public key is present in the metadata. Parameters: tx_id: The ID of the transaction. public_key: The public key to search for in the metadata. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_asset(tx_id: str, public_key: str) -> dict Retrieves the block containing a specific transaction related to an asset owned by the public key. Parameters: tx_id: The ID of the transaction. public_key: The public key of the asset owner. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_operation(tx_id: str, public_key: str, operation: str) -> dict Retrieves the block containing a specific transaction of a given operation type associated with a public key. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. operation: The type of operation. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_timestamp(tx_id: str, public_key: str, start_time: int, end_time: int) -> dict Retrieves the block containing a specific transaction associated with a public key within a timestamp range. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. start_time: The start timestamp (Unix epoch time). end_time: The end timestamp (Unix epoch time). Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_hash_prefix(tx_id: str, public_key: str, hash_prefix: str) -> dict Retrieves the block containing a specific transaction associated with a public key whose hash starts with a prefix. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. hash_prefix: The prefix of the transaction hash. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_metadata_key(tx_id: str, public_key: str, metadata_key: str) -> dict Retrieves the block containing a specific transaction associated with a public key and a metadata key. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. metadata_key: The key of the metadata field. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_metadata_value(tx_id: str, public_key: str, metadata_value: str) -> dict Retrieves the block containing a specific transaction associated with a public key and a metadata value. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. metadata_value: The value of the metadata field. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_asset_id(tx_id: str, public_key: str, asset_id: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an asset ID. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. asset_id: The ID of the asset. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_condition_type(tx_id: str, public_key: str, condition_type: str) -> dict Retrieves the block containing a specific transaction associated with a public key and a condition type. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. condition_type: The type of condition. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_fulfillment_type(tx_id: str, public_key: str, fulfillment_type: str) -> dict Retrieves the block containing a specific transaction associated with a public key and a fulfillment type. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. fulfillment_type: The type of fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_amount(tx_id: str, public_key: str, amount: int) -> dict Retrieves the block containing a specific transaction associated with a public key and an output amount. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. amount: The amount of the output. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_condition_type(tx_id: str, public_key: str, output_index: int, condition_type: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output condition type. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. condition_type: The type of condition in the output. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_type(tx_id: str, public_key: str, output_index: int, fulfillment_type: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment type. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_type: The type of fulfillment in the output. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_public_key(tx_id: str, public_key: str, output_index: int, fulfillment_public_key: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment public key. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_public_key: The public key in the output fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_signature(tx_id: str, public_key: str, output_index: int, fulfillment_signature: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment signature. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_signature: The signature in the output fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_hash(tx_id: str, public_key: str, output_index: int, fulfillment_hash: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment hash. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_hash: The hash in the output fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_sequence(tx_id: str, public_key: str, output_index: int, fulfillment_sequence: int) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment sequence number. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_sequence: The sequence number in the output fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage hash. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_hash: The preimage hash in the output fulfillment. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_public_key(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_public_key: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage public key. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_public_key: The public key in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_signature(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_signature: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage signature. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_signature: The signature in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash_prefix(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash_prefix: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage hash prefix. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_hash_prefix: The hash prefix in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash_value(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash_value: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage hash value. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_hash_value: The hash value in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash_type(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash_type: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage hash type. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_hash_type: The hash type in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash_algorithm(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash_algorithm: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage hash algorithm. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_hash_algorithm: The hash algorithm in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash_salt(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash_salt: str) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage hash salt. Parameters: tx_id: The ID of the transaction. public_key: The public key associated with the transaction. output_index: The index of the output. fulfillment_preimage_hash_salt: The hash salt in the output fulfillment preimage. Returns: A dictionary representing the block if found, otherwise None. get_block_by_tx_public_key_in_output_fulfillment_preimage_hash_iterations(tx_id: str, public_key: str, output_index: int, fulfillment_preimage_hash_iterations: int) -> dict Retrieves the block containing a specific transaction associated with a public key and an output fulfillment preimage ``` -------------------------------- ### Prepare Transfer Transaction Input Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Prepares the input for a transfer transaction, specifying the asset to be transferred and the previous owner's details. ```ipython In [0]: asset_id = creation_tx['id'] In [0]: transfer_asset = { ...: 'id': asset_id, ...: } In [0]: output_index = 0 In [0]: output = creation_tx['outputs'][output_index] In [0]: transfer_input = { ...: 'fulfillment': output['condition']['details'], ...: 'fulfills': { ...: 'output_index': output_index, ...: 'transaction_id': creation_tx['id'], ...: }, ...: 'owners_before': output['public_keys'], ...: } ``` -------------------------------- ### Updating Driver and Setup Files Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/RELEASE_PROCESS.md Shows the specific files to update during the release process: __init__.py for the driver version and setup.py for version and development status classifiers. ```python # In bigchaindb-driver/__init__.py: __version__ = "0.9.0" # In setup.py: # Update version and development status classifiers ``` -------------------------------- ### Download BigchainDB Python Driver Tarball Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/advanced-installation.rst Downloads the source code tarball for the BigchainDB Python Driver from GitHub using curl. ```bash curl -OL https://github.com/bigchaindb/bigchaindb-driver/tarball/master ``` -------------------------------- ### Create Time Share Token Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Defines the structure for a time-share token representing one hour of riding time for a bicycle. This is the initial asset creation step. ```python bicycle_token = { 'data': { 'token_for': { 'bicycle': { 'serial_number': 'abcd1234', 'manufacturer': 'bkfab' } }, 'description': 'Time share token. Each token equals one hour of riding.', }, } ``` -------------------------------- ### Initialize BigchainDB Connection and Generate Keypairs Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/advanced-usage.rst Sets up a connection to a BigchainDB instance and generates cryptographic key pairs for Alice and Bob. This is a prerequisite for performing most BigchainDB operations. ```python from bigchaindb_driver import BigchainDB from bigchaindb_driver.crypto import generate_keypair bdb_root_url = 'https://example.com:9984' # Use YOUR BigchainDB Root URL here bdb = BigchainDB(bdb_root_url) alice, bob = generate_keypair(), generate_keypair() ``` -------------------------------- ### Crypto-Conditions Introduction Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/advanced-usage.rst Provides an introduction to Crypto-Conditions, explaining their role in describing signed messages for verification in distributed systems and their relation to the Interledger protocol. ```APIDOC Crypto-Conditions (Advanced) Introduction ~~~~~~~~~~~~ Crypto-conditions provide a mechanism to describe a signed message such that multiple actors in a distributed system can all verify the same signed message and agree on whether it matches the description. This provides a useful primitive for event-based systems that are distributed on the Internet since we can describe events in a standard deterministic manner (represented by signed messages) and therefore define generic authenticated event handlers. Crypto-conditions are part of the Interledger protocol and the full specification can be found `here `_. Implementations of the crypto-conditions are available in `Python `_, `JavaScript `_, and `Java `_. ``` -------------------------------- ### PyPI Publishing Command Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/RELEASE_PROCESS.md Provides the command used to build and publish the new bigchaindb-driver package to PyPI, requiring twine to be installed. ```makefile make release ``` -------------------------------- ### Define Metadata Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Illustrates how to optionally add metadata to a transaction. Any dictionary can be used for metadata, providing additional context to the transaction. ```ipython metadata = {'planet': 'earth'} ``` -------------------------------- ### Fulfill Asset Creation Transaction Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Fulfills a prepared transaction by signing it with the appropriate private key. This step is necessary before the transaction can be submitted to the network. ```ipython fulfilled_creation_tx = bdb.transactions.fulfill( prepared_creation_tx, private_keys=alice.private_key) ``` -------------------------------- ### Development Environment with Docker Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/CONTRIBUTING.rst Instructions for setting up a development environment using Docker to run a BigchainDB node. This includes starting the BigchainDB node, monitoring logs, and using provided Makefile commands for various development tasks. ```shell # Implicitly creates a MongoDB and Tendermint instance $ docker-compose up -d bigchaindb ``` ```shell $ docker-compose logs -f ``` -------------------------------- ### Get CREATE Transactions by Asset ID Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Retrieves all 'CREATE' operations associated with a specific asset ID. This is useful for filtering transaction history related to a particular asset. ```python bdb.transactions.get(asset_id=sent_token_tx['id'], operation='CREATE') ``` -------------------------------- ### Install Ubuntu Dependencies Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/quickstart.rst Installs necessary development libraries (python3-dev, libssl-dev, libffi-dev) on Ubuntu systems. ```bash sudo apt-get update sudo apt-get install python3-dev libssl-dev libffi-dev ``` -------------------------------- ### Asset Creation and Transfer Workflow Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/usage.rst Demonstrates the complete workflow of creating an asset and then transferring it to another party. This includes generating keypairs, preparing, fulfilling, and sending transactions. ```python from bigchaindb_driver import BigchainDB from bigchaindb_driver.crypto import generate_keypair from time import sleep from sys import exit alice, bob = generate_keypair(), generate_keypair() bdb_root_url = 'https://example.com:9984' # Use YOUR BigchainDB Root URL here bdb = BigchainDB(bdb_root_url) bicycle_asset = { 'data': { 'bicycle': { 'serial_number': 'abcd1234', 'manufacturer': 'bkfab' }, }, } bicycle_asset_metadata = { 'planet': 'earth' } prepared_creation_tx = bdb.transactions.prepare( operation='CREATE', signers=alice.public_key, asset=bicycle_asset, metadata=bicycle_asset_metadata ) fulfilled_creation_tx = bdb.transactions.fulfill( prepared_creation_tx, private_keys=alice.private_key ) sent_creation_tx = bdb.transactions.send_commit(fulfilled_creation_tx) txid = fulfilled_creation_tx['id'] asset_id = txid transfer_asset = { 'id': asset_id } output_index = 0 output = fulfilled_creation_tx['outputs'][output_index] transfer_input = { 'fulfillment': output['condition']['details'], 'fulfills': { 'output_index': output_index, 'transaction_id': fulfilled_creation_tx['id'] }, 'owners_before': output['public_keys'] } prepared_transfer_tx = bdb.transactions.prepare( operation='TRANSFER', asset=transfer_asset, inputs=transfer_input, recipients=bob.public_key, ) fulfilled_transfer_tx = bdb.transactions.fulfill( prepared_transfer_tx, private_keys=alice.private_key, ) sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx) print("Is Bob the owner?", sent_transfer_tx['outputs'][0]['public_keys'][0] == bob.public_key) print("Was Alice the previous owner?", ``` -------------------------------- ### Build Documentation with Docker Compose Source: https://github.com/bigchaindb/bigchaindb-driver/blob/master/docs/aboutthedocs.rst This snippet shows how to build the BigchainDB driver documentation using Docker Compose. It involves running a Docker container that builds the documentation in HTML format. ```bash docker-compose up -d bdocs ```