1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-24 19:10:12 +01:00
js-bigchaindb-driver/docs/source/readme.rst

121 lines
4.3 KiB
ReStructuredText
Raw Normal View History

.. Copyright BigchainDB GmbH and BigchainDB contributors
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
Code is Apache-2.0 and docs are CC-BY-4.0
BigchainDB JavaScript Driver
============================
.. image:: https://img.shields.io/npm/v/bigchaindb-driver.svg
:target: https://www.npmjs.com/package/bigchaindb-driver
.. image:: https://codecov.io/gh/bigchaindb/js-bigchaindb-driver/branch/master/graph/badge.svg
:target: https://codecov.io/gh/bigchaindb/js-bigchaindb-driver
.. image:: https://img.shields.io/badge/js-ascribe-39BA91.svg
:target: https://github.com/ascribe/javascript
2018-12-11 20:25:16 +01:00
.. image:: https://travis-ci.com/bigchaindb/js-bigchaindb-driver.svg?branch=master
:target: https://travis-ci.com/bigchaindb/js-bigchaindb-driver
.. image:: https://badges.greenkeeper.io/bigchaindb/js-bigchaindb-driver.svg
:target: https://greenkeeper.io/
Features
--------
* Support for preparing, fulfilling, and sending transactions to a BigchainDB
node.
* Retrieval of transactions by id.
* Getting status of a transaction by id.
Compatibility Matrix
--------------------
+-----------------------+----------------------------------+
| **BigchainDB Server** | **BigchainDB Javascript Driver** |
+=======================+==================================+
| ``0.10`` | ``0.1.x`` |
+-----------------------+----------------------------------+
| ``1.0`` | ``0.3.x`` |
+-----------------------+----------------------------------+
2017-12-20 11:32:34 +01:00
| ``1.3`` | ``3.x.x`` |
2017-12-19 16:56:16 +01:00
+-----------------------+----------------------------------+
2018-03-27 09:07:31 +02:00
| ``2.0`` | ``4.x.x`` |
+-----------------------+----------------------------------+
2017-12-19 16:56:16 +01:00
Older versions
--------------------
2018-03-27 09:07:31 +02:00
2018-04-03 10:43:25 +02:00
**Version 4.x.x**
2018-04-04 10:44:15 +02:00
As part of the changes in the BigchainDB 2.0 server, some endpoints were
2018-04-03 10:43:25 +02:00
modified. In order to be consistent with them, the JS driver does not have
anymore the `pollStatusAndFetchTransaction()` method as there are three
2018-04-04 10:44:15 +02:00
different ways of posting a transaction:
2018-06-19 16:58:42 +02:00
- `commit` using the `postTransaction` or the `postTransactionCommit`: the response will return after the transaction is committed to a block.
2018-04-03 10:43:25 +02:00
- `sync` using the `postTransactionSync`: the response will return after the transaction is validated.
2018-06-19 16:58:42 +02:00
- `async` using the `postTransactionAsync`: the response will return immediately and not wait to see if the transaction is valid.
2018-03-28 17:03:26 +02:00
2018-04-03 10:43:25 +02:00
By default in the docs we will use the `postTransactionCommit` as is way of
being sure that the transaction is validated and commited to a block, so
2018-04-04 10:44:15 +02:00
there will not be any issue if you try to do any other action with the asset immediately.
2018-03-28 17:03:26 +02:00
2018-06-19 16:58:42 +02:00
Note: In order to not create breaking changes, both methods `postTransaction` and `postTransactionCommit` are kept although
they do exactly the same
2018-03-27 09:07:31 +02:00
2018-04-03 10:43:25 +02:00
**Version 3.2.x**
2018-03-27 09:07:31 +02:00
2018-04-03 10:43:25 +02:00
For versions below 3.2, a transfer transaction looked like:
2018-03-27 09:07:31 +02:00
2018-04-03 10:43:25 +02:00
.. code-block:: js
2018-03-28 17:03:26 +02:00
2018-04-03 10:43:25 +02:00
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
txCreated,
metadata, [BigchainDB.Transaction.makeOutput(
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
0
)
2017-12-19 16:56:16 +01:00
2018-04-03 10:43:25 +02:00
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
keypair.privateKey)
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
In order to upgrade and do it compatible with the new driver version, this
transaction should be now:
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
.. code-block:: js
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
[{ tx: txCreated, output_index: 0 }],
[BigchainDB.Transaction.makeOutput(
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
metaData
)
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
keypair.privateKey)
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
The upgrade allows to create transfer transaction spending outputs that belong
to different transactions. So for instance is now possible to create a transfer
transaction spending two outputs from two different create transactions:
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
.. code-block:: js
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
const createTranfer = BigchainDB.Transaction.makeTransferTransaction(
[{ tx: txCreated1, output_index: 0 },
{ tx: txCreated2, output_index: 0}],
[BigchainDB.Transaction.makeOutput(
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))],
metaData
)
2017-12-20 11:32:34 +01:00
2018-04-03 10:43:25 +02:00
const signedTransfer = BigchainDB.Transaction.signTransaction(createTranfer,
keypair.privateKey)