Skip to content

RiddleAndCode/bigchaindb-c-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ANSI C driver for BigchainDB

This ANSI C driver enables developers to create, sign and send BigchainDB transactions to BigchainDB servers and has been used within several MCU based projects within RIDDLE&CODE.

Please note: This driver is written in C but is due to the C/C++ relation compatible with C++ by default.

Install

Clone the git repository and the submodules

$ git clone https://github.com/RiddleAndCode/bigchaindb-c-driver.git
$ git submodule update --init --recursive

Having that, the compilation process can be started by running the cmake and make build process. Please ensure that you have cmake and make installed on your system:

mkdir build
cd build/
cmake ..
make
ctest

Usage

The creation and siging of transaction on BigchainDB is simple. Inputs are taken and transfered to outputs. The inputs and outputs have to be prepared and defined.

The test code of this project contains all of this aspects and can be used to create simple transactions. The support for more complex transactions is missing at this point in time.

First the transactin is prepared (this is in most cases a very specific task), thereafter build, signed, fulfilled and serialized.

Now, the transaction can be submitted to the BigchainDB nodes.

  BIGCHAIN_TX tx;
  char json[6000] = {0};

  memset(&tx, 0, sizeof(BIGCHAIN_TX));
  prepare_tx(&tx);
  bigchain_build_json_tx(&tx, json);
 
  char sig[128] = {0};
  bigchain_sign_transaction((uint8_t*)json, strlen(json), (uint8_t*)privkey, (uint8_t*)pubkey,  (uint8_t*)sig);
  bigchain_fulfill_and_serialize(&tx, (uint8_t*)json, 6000, (uint8_t*)sig, (uint8_t*)pubkey);

Note

When building the metadata and asset objects take the following measures:

  1. No spaces in the json structure: {"key 1": "value a"} becomes '{"key 2":"value a"}'
  2. Keys should be alphabetically ordered: {"key 1":"value a","A key":"A value"} becomes {"A key":"A value","key 1":"value a"}
  3. No numbers fields, only strings {"key 1":2.3123} becomes {"key 1":"2.3123"}

BigchainDB Documentation

Compatibility Matrix

The driver should be compatible with BigchainDB version 2.x but got only actively tested with BigchainDB v2.0.0b9. It might work with earlier versions but hasn't been tested with them.

BigchainDB Server BigchainDB C driver
2.x 1.x

Authors

The RIDDLE&CODE team.

Support

Included code/APIs provided as is. If you find an issue with API, pleaes submit the issue. Help is always availabl at RIDDLE&CODE.

About

Transaction buider and signer for bigchaindb.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 5