{"id":19724762,"url":"https://github.com/bigchaindb/js-bigchaindb-driver","last_synced_at":"2025-04-04T21:09:00.245Z","repository":{"id":20742078,"uuid":"90778469","full_name":"bigchaindb/js-bigchaindb-driver","owner":"bigchaindb","description":"Official BigchainDB JavaScript driver for Node.js and the browser","archived":false,"fork":false,"pushed_at":"2022-02-17T05:09:20.000Z","size":8274,"stargazers_count":216,"open_issues_count":29,"forks_count":92,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-30T06:16:48.462Z","etag":null,"topics":["bigchaindb-driver","nodejs"],"latest_commit_sha":null,"homepage":"https://docs.bigchaindb.com/projects/js-driver/en/latest/usage.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigchaindb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-09T18:22:33.000Z","updated_at":"2024-04-29T16:29:37.000Z","dependencies_parsed_at":"2022-07-25T08:01:56.265Z","dependency_job_id":null,"html_url":"https://github.com/bigchaindb/js-bigchaindb-driver","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigchaindb%2Fjs-bigchaindb-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigchaindb%2Fjs-bigchaindb-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigchaindb%2Fjs-bigchaindb-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigchaindb%2Fjs-bigchaindb-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigchaindb","download_url":"https://codeload.github.com/bigchaindb/js-bigchaindb-driver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249528,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigchaindb-driver","nodejs"],"created_at":"2024-11-11T23:26:57.448Z","updated_at":"2025-04-04T21:09:00.226Z","avatar_url":"https://github.com/bigchaindb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!---\nCopyright BigchainDB GmbH and BigchainDB contributors\nSPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\nCode is Apache-2.0 and docs are CC-BY-4.0\n---\u003e\n\n# [![js-bigchaindb-driver](media/repo-banner@2x.png)](https://www.bigchaindb.com)\n\n\u003e Official JavaScript driver for [BigchainDB](https://github.com/bigchaindb/bigchaindb) to create transactions in Node.js and the browser.\n\n[![Join the chat at https://gitter.im/bigchaindb/js-bigchaindb-driver](https://badges.gitter.im/bigchaindb/js-bigchaindb-driver.svg)](https://gitter.im/bigchaindb/js-bigchaindb-driver?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![npm](https://img.shields.io/npm/v/bigchaindb-driver.svg)](https://www.npmjs.com/package/bigchaindb-driver)\n[![codecov](https://codecov.io/gh/bigchaindb/js-bigchaindb-driver/branch/master/graph/badge.svg)](https://codecov.io/gh/bigchaindb/js-bigchaindb-driver)\n[![js ascribe](https://img.shields.io/badge/js-ascribe-39BA91.svg)](https://github.com/ascribe/javascript)\n[![Build Status](https://travis-ci.com/bigchaindb/js-bigchaindb-driver.svg?branch=master)](https://travis-ci.com/bigchaindb/js-bigchaindb-driver)\n[![Greenkeeper badge](https://badges.greenkeeper.io/bigchaindb/js-bigchaindb-driver.svg)](https://greenkeeper.io/)\n\n- [Main Documentation](https://docs.bigchaindb.com/projects/js-driver/en/latest/usage.html)\n- [Driver API reference](API.md)\n\n## Compatibility\n\n| BigchainDB Server | BigchainDB JavaScript Driver |\n| ----------------- |------------------------------|\n| `0.10`            | `0.1.x`                      |\n| `1.0.0`           | `0.3.x`                      |\n| `1.3.x`           | `3.x.x`                      |\n| `\u003e= 2.0.0`        | `4.x.x`                      |\n\n## Breaking changes\n\n- **Version 4.0** of BigchainDB JavaScript Driver makes the driver compatible with BigchainDB 2.0. There are new functions for sending off transactions along with other changes. Check [older versions](https://docs.bigchaindb.com/projects/js-driver/en/latest/readme.html#features)\n- **Version 3.2** of BigchainDB JavaScript Driver introduces a new way of creating transfer transactions. Check [older versions](https://docs.bigchaindb.com/projects/js-driver/en/latest/readme.html#features)\n\n## Table of Contents\n\n  - [Installation and Usage](#installation-and-usage)\n     - [Example: Create a transaction](#example-create-a-transaction)\n     - [Browser usage](#browser-usage)\n  - [BigchainDB Documentation](#bigchaindb-documentation)\n  - [Speed Optimizations](#speed-optimizations)\n  - [Development](#development)\n  - [Release Process](#release-process)\n  - [Authors](#authors)\n  - [Licenses](#licenses)\n\n---\n\n## Installation and Usage\n\n```bash\nnpm install bigchaindb-driver\n```\n\n```js\nconst driver = require('bigchaindb-driver')\n// or ES6+\nimport driver from 'bigchaindb-driver'\n```\n\n### Example: Create a transaction\n\n```js\nconst driver = require('bigchaindb-driver')\nconst base58 = require('bs58');\nconst crypto = require('crypto');\nconst { Ed25519Sha256 } = require('crypto-conditions');\n\n// BigchainDB server instance (e.g. https://example.com/api/v1/)\nconst API_PATH = 'http://localhost:9984/api/v1/'\n\n// Create a new keypair.\nconst alice = new driver.Ed25519Keypair()\n\n// Construct a transaction payload\nconst tx = driver.Transaction.makeCreateTransaction(\n    // Define the asset to store, in this example it is the current temperature\n    // (in Celsius) for the city of Berlin.\n    { city: 'Berlin, DE', temperature: 22, datetime: new Date().toString() },\n\n    // Metadata contains information about the transaction itself\n    // (can be `null` if not needed)\n    { what: 'My first BigchainDB transaction' },\n\n    // A transaction needs an output\n    [ driver.Transaction.makeOutput(\n            driver.Transaction.makeEd25519Condition(alice.publicKey))\n    ],\n    alice.publicKey\n)\n\n// Sign the transaction with private keys\nconst txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)\n\n// Or use delegateSignTransaction to provide your own signature function\nfunction signTransaction() {\n    // get privateKey from somewhere\n    const privateKeyBuffer = Buffer.from(base58.decode(alice.privateKey))\n    return function sign(serializedTransaction, input, index) {\n        const transactionUniqueFulfillment = input.fulfills ? serializedTransaction\n                .concat(input.fulfills.transaction_id)\n                .concat(input.fulfills.output_index) : serializedTransaction\n        const transactionHash = crypto.createHash('sha3-256').update(transactionUniqueFulfillment).digest()\n        const ed25519Fulfillment = new Ed25519Sha256();\n        ed25519Fulfillment.sign(transactionHash, privateKeyBuffer);\n        return ed25519Fulfillment.serializeUri();\n    };\n}\nconst txSigned = driver.Transaction.delegateSignTransaction(tx, signTransaction())\n\n// Send the transaction off to BigchainDB\nconst conn = new driver.Connection(API_PATH)\n\nconn.postTransactionCommit(txSigned)\n    .then(retrievedTx =\u003e console.log('Transaction', retrievedTx.id, 'successfully posted.'))\n```\n\n### Browser usage\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003ctitle\u003eBigchainDB boilerplate\u003c/title\u003e\n        \u003c!-- Adjust version to your needs --\u003e\n        \u003cscript src=\"https://unpkg.com/bigchaindb-driver@4.2.0/dist/browser/bigchaindb-driver.window.min.js\"\u003e\u003c/script\u003e\n\n        \u003cscript\u003e\n            // BigchainDB server instance (e.g. https://example.com/api/v1/)\n            const API_PATH = 'http://localhost:9984/api/v1/'\n\n            // Create a new keypair.\n            const alice = new BigchainDB.Ed25519Keypair()\n\n            // Construct a transaction payload\n            const tx = BigchainDB.Transaction.makeCreateTransaction(\n                // Define the asset to store, in this example it is the current temperature\n                // (in Celsius) for the city of Berlin.\n                { city: 'Berlin, DE', temperature: 22, datetime: new Date().toString() },\n\n                // Metadata contains information about the transaction itself\n                // (can be `null` if not needed)\n                { what: 'My first BigchainDB transaction' },\n\n                // A transaction needs an output\n                [ BigchainDB.Transaction.makeOutput(\n                        BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))\n                ],\n                alice.publicKey\n            )\n\n            // Sign the transaction with private keys\n            const txSigned = BigchainDB.Transaction.signTransaction(tx, alice.privateKey)\n\n            // Send the transaction off to BigchainDB\n            let conn = new BigchainDB.Connection(API_PATH)\n\n            conn.postTransactionCommit(txSigned)\n                .then(res =\u003e {\n                    const elem = document.getElementById('lastTransaction')\n                    elem.href = API_PATH + 'transactions/' + txSigned.id\n                    elem.innerText = txSigned.id\n                    console.log('Transaction', txSigned.id, 'accepted')\n                })\n            // Check console for the transaction's status\n        \u003c/script\u003e\n    \u003c/head\u003e\n    \u003cbody id=\"home\"\u003e\n        \u003ch1\u003eHello BigchainDB\u003c/h1\u003e\n        \u003cp\u003eYour transaction id is: \u003ca id=\"lastTransaction\" target=\"_blank\"\u003e\u003cem\u003eprocessing\u003c/em\u003e\u003c/a\u003e\u003c/p\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## BigchainDB Documentation\n\n- [The Hitchhiker's Guide to BigchainDB](https://www.bigchaindb.com/developers/guide/)\n- [HTTP API Reference](https://docs.bigchaindb.com/projects/server/en/latest/http-client-server-api.html)\n- [The Transaction Model](https://docs.bigchaindb.com/projects/server/en/latest/data-models/transaction-model.html?highlight=crypto%20conditions)\n- [Inputs and Outputs](https://docs.bigchaindb.com/projects/server/en/latest/data-models/inputs-outputs.html)\n- [Asset Transfer](https://docs.bigchaindb.com/projects/py-driver/en/latest/usage.html#asset-transfer)\n- [All BigchainDB Documentation](https://docs.bigchaindb.com/)\n\n## Speed Optimizations\n\nThis implementation plays \"safe\" by using JS-native (or downgradable) libraries for its crypto-related functions to keep compatibilities with the browser. If you do want some more speed, feel free to explore the following:\n\n* [chloride](https://github.com/dominictarr/chloride), or its underlying [sodium](https://github.com/paixaop/node-sodium) library\n* [node-sha3](https://github.com/phusion/node-sha3) -- **MAKE SURE** to use [steakknife's fork](https://github.com/steakknife/node-sha3) if [the FIPS 202 upgrade](https://github.com/phusion/node-sha3/pull/25) hasn't been merged (otherwise, you'll run into all kinds of hashing problems)\n\n## Development\n\n```js\ngit clone git@github.com:bigchaindb/js-bigchaindb-driver.git\ncd js-bigchaindb-driver/\n\nnpm i\nnpm run dev\n```\n\nAfter updating source files in `src/`, make sure to update the API documentation. The following command will scan all source files and create the Markdown output into `./API.md`:\n\n```bash\nnpm run doc\n```\n\n## Release Process\n\nSee the file named [RELEASE_PROCESS.md](RELEASE_PROCESS.md).\n\n## Authors\n\n* inspired by [`js-bigchaindb-quickstart`](https://github.com/sohkai/js-bigchaindb-quickstart) of @sohkhai [thanks]\n* BigchainDB \u003ccontact@ipdb.global\u003e\n* BigchainDB contributors\n\n## Licenses\n\nSee [LICENSE](LICENSE) and [LICENSE-docs](LICENSE-docs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigchaindb%2Fjs-bigchaindb-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigchaindb%2Fjs-bigchaindb-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigchaindb%2Fjs-bigchaindb-driver/lists"}