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)
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 |
BigchainDB Server | BigchainDB PHP Driver |
---|---|
Still under development |
#composer require kryuu-common/big-chain-db-driver (comming soon, for now please use git)
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.')
});
- The Hitchhiker's Guide to BigchainDB
- HTTP API Reference
- The Transaction Model
- Inputs and Outputs
- Asset Transfer
- All BigchainDB Documentation
- inspired by
js-bigchaindb-quickstart
of @sohkhai [thanks] - re-written from
js-bigchaindb-driver
- Anders Blenstrup-Pedersen @
katsuoryuu.org
MIT