Skip to content

KatsuoRyuu/php-BigChainDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Big Chain DB - PHP Driver

This is a rewrite of the Big Chain DB - JS Driver, written in PHP, the functionality and interaction is almost if not the same as the JS Driver


Main repo: https://git.ryuu.technology/KryuuCommon/BigChainDB


unofficial PHP driver for BigchainDB to create transactions in PHP.

Driver API reference (in progress)

Progress

Part status
Ed25519Keypair done (part of https://git.ryuu.technology/KryuuCommon/Buffer)
baseRequest Started
Connection almost done
format_text done
index Not needed
request done
sanitize Queued
sha256Hash done
stringify_as_query_param Queued
transaction almost done
Utils/ccJsonLoad Queued
Utils/ccJsonify Queued

Compatibility

BigchainDB Server BigchainDB PHP Driver
Still under development

Table of Contents


Installation and Usage

#composer require kryuu-common/big-chain-db-driver (comming soon, for now please use git)

Example: Create a transaction

use KryuuCommon\BigChainDB\Driver;

$driver = new Driver();

// BigchainDB server instance (e.g. https://test.bigchaindb.com/api/v1/)
$API_PATH = 'http://localhost:9984/api/v1/'

// Create a new keypair.
$alice = new $driver->Ed25519Keypair()

// Construct a transaction payload
$tx = $driver->getTransaction()->makeCreateTransaction(
    // Define the asset to store, in this example it is the current temperature
    // (in Celsius) for the city of Berlin.
    [ 'city' => 'Berlin, DE', 'temperature' => 22, 'datetime' => date('D M d Y H:i:s \G\M\TO (T)')],

    // Metadata contains information about the transaction itself
    // (can be `null` if not needed)
    [ 'what' => 'My first BigchainDB transaction' ],

    // A transaction needs an output
    [ $driver->getTransaction()->makeOutput(
            $driver->getTransaction()->makeEd25519Condition($alice->publicKey))
    ],
    $alice->publicKey
)

// Sign the transaction with private keys
$txSigned = $driver->getTransaction->signTransaction($tx, $alice->privateKey)

// Send the transaction off to BigchainDB
$conn = $driver->Connection($API_PATH);

$conn->postTransactionCommit($txSigned)
    ->then(funrtion($retrievedTx) { 
        print_r( 'Transaction: ' . $retrievedTx->id . 'successfully posted.')
    });

BigchainDB Documentation

Authors

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages