|
2 | 2 | Copyright RiddleandCode |
3 | 3 | ---> |
4 | 4 |
|
5 | | -Install |
6 | | ----------- |
| 5 | + |
| 6 | +# ANSI C driver for BigchainDB |
| 7 | + |
| 8 | +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. |
| 9 | + |
| 10 | +**Please note**: This driver is written in C but is due to the C/C++ relation compatible with C++ by default. |
| 11 | + |
| 12 | + |
| 13 | +## Install |
| 14 | + |
| 15 | + |
| 16 | +Clone the git repository and the submodules |
| 17 | + |
| 18 | +``` |
| 19 | +$ git clone https://github.com/RiddleAndCode/bigchaindb-c-driver.git |
| 20 | +$ git submodule update --init --recursive |
| 21 | +``` |
| 22 | + |
| 23 | +Having that, the compilation process can be started by running the cmake and make build process. |
| 24 | +Please ensure that you have cmake and make installed on your system: |
| 25 | + |
7 | 26 | ``` |
8 | 27 | mkdir build |
9 | 28 | cd build/ |
10 | 29 | cmake .. |
11 | 30 | make |
12 | 31 | ctest |
13 | 32 | ``` |
14 | | -## Note |
| 33 | + |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +The creation and siging of transaction on BigchainDB is simple. Inputs are taken and transfered to outputs. |
| 38 | +The inputs and outputs have to be prepared and defined. |
| 39 | + |
| 40 | + |
| 41 | +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. |
| 42 | + |
| 43 | +First the transactin is prepared (this is in most cases a very specific task), thereafter |
| 44 | +build, signed, fulfilled and serialized. |
| 45 | + |
| 46 | +Now, the transaction can be submitted to the BigchainDB nodes. |
| 47 | + |
| 48 | +``` |
| 49 | + BIGCHAIN_TX tx; |
| 50 | + char json[6000] = {0}; |
| 51 | +
|
| 52 | + memset(&tx, 0, sizeof(BIGCHAIN_TX)); |
| 53 | + prepare_tx(&tx); |
| 54 | + bigchain_build_json_tx(&tx, json); |
| 55 | + |
| 56 | + char sig[128] = {0}; |
| 57 | + bigchain_sign_transaction((uint8_t*)json, strlen(json), (uint8_t*)privkey, (uint8_t*)pubkey, (uint8_t*)sig); |
| 58 | + bigchain_fulfill_and_serialize(&tx, (uint8_t*)json, 6000, (uint8_t*)sig, (uint8_t*)pubkey); |
| 59 | +
|
| 60 | +``` |
| 61 | + |
| 62 | + |
| 63 | +### Note |
15 | 64 | When building the metadata and asset objects take the following measures: |
16 | 65 | 1. No spaces in the json structure: ```{"key 1": "value a"}``` becomes ```'{"key 2":"value a"}'``` |
17 | 66 | 2. Keys should be alphabetically ordered: ```{"key 1":"value a","A key":"A value"}``` becomes ```{"A key":"A value","key 1":"value a"}``` |
18 | 67 | 3. No numbers fields, only strings ```{"key 1":2.3123}``` becomes ```{"key 1":"2.3123"}``` |
19 | 68 |
|
20 | 69 |
|
21 | | -BigchainDB Documentation |
22 | | ------------------------------------- |
23 | | -* `BigchainDB Server Quickstart`_ |
24 | | -* `The Hitchhiker's Guide to BigchainDB`_ |
25 | | -* `HTTP API Reference`_ |
26 | | -* `All BigchainDB Documentation`_ |
27 | 70 |
|
28 | | -Usage |
29 | | ----------- |
30 | | -test_bigchain_build_json_tx(); |
31 | 71 |
|
| 72 | +## BigchainDB Documentation |
| 73 | + |
| 74 | +* [BigchainDB Server Quickstart](http://docs.bigchaindb.com/projects/server/en/latest/quickstart.html) |
| 75 | +* [The Hitchhiker's Guide to BigchainDB](https://www.bigchaindb.com/developers/guide/) |
| 76 | +* [HTTP API Reference](http://docs.bigchaindb.com/projects/server/en/latest/http-client-server-api.html) |
| 77 | +* [All BigchainDB Documentation](https://docs.bigchaindb.com/en/latest/) |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +## Compatibility Matrix |
| 82 | + |
| 83 | +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. |
| 84 | + |
| 85 | +| BigchainDB Server | BigchainDB C driver | |
| 86 | +| ----------------- |------------------------------| |
| 87 | +| `2.x` | `1.x` | |
| 88 | + |
| 89 | + |
| 90 | +## Authors |
| 91 | + |
| 92 | +The RIDDLE&CODE team. |
| 93 | + |
| 94 | + |
| 95 | +## Support |
32 | 96 |
|
33 | | -Compatibility Matrix |
34 | | --------------------- |
35 | | - **BigchainDB Server** |
36 | | - ``>= 2.0.0b7`` |
| 97 | +Included code/APIs provided as is. If you find an issue with API, pleaes submit the issue. Help is always availabl at RIDDLE&CODE. |
37 | 98 |
|
38 | | -License |
39 | | --------- |
40 | | -* `licenses`_ - open source & open content |
41 | 99 |
|
0 commit comments