# bbc1-simple-library

> Name ===== BBc-1(Beyond Block-chain One) Library, written in Javascript.

Latest version **0.1.2** (published 2018-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install bbc1-simple-library
pnpm add bbc1-simple-library
yarn add bbc1-simple-library
bun add bbc1-simple-library
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-10-15 |
| First published | 2018-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Takeshi Hashimoto |
| Maintainers | tk-hashimoto |
| Keywords | BBc-1, Block-chain, bbclib |

## Links

- npm: https://www.npmjs.com/package/bbc1-simple-library
- Repository: https://github.com/t-hashimoto249/js-bbclib
- Homepage: https://github.com/t-hashimoto249/js-bbclib/#readme
- Issues: https://github.com/t-hashimoto249/js-bbclib/issues
- npm.io page: https://npm.io/package/bbc1-simple-library

## Dependencies (10)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [net](https://npm.io/package/net.md) ^1.0.2
- [tls](https://npm.io/package/tls.md) 0.0.1
- [bson](https://npm.io/package/bson.md) ^3.0.0
- [code](https://npm.io/package/code.md) ^5.2.0
- [json](https://npm.io/package/json.md) ^9.0.6
- [buffer](https://npm.io/package/buffer.md) ^5.1.0
- [winston](https://npm.io/package/winston.md) ^3.0.0
- [js-crypto-utils](https://npm.io/package/js-crypto-utils.md) ^0.10.1
- [js-encoding-utils](https://npm.io/package/js-encoding-utils.md) ^0.2.6

## Recent versions

- 0.1.2 (latest) — 2018-10-15

## README

Name
=====
BBc-1(Beyond Block-chain One) Library, written in Javascript. 

# Overview
The library is implemented bbclib and bbc-app-rest-api functions on platform of BBc-1.
It provides make transaction function, sign and verify transaction function, serialize and deserialize function for some collection of data on BBc-1 platform. (They are BBcTransaction, BBcEvent, BBcAsset, BBcSignature, BBcRelation, BBcReference, BBcCrossRef, BBcPointer and BBcWitness).
It works on modern browsers(Firefox, IE, Edge, Chrome and Safari) and Node.js. 
The module is totally written in ES6+ and needed to get transpiled with babel for legacy environments.

※The design and detail of BBc-1 is following.<br>
BBc-1: https://github.com/beyond-blockchain/bbc1
  
# Installation
At your project directory, do either one of the following.

・From npm/yarn:
```$xslt
$ npm install --save js-bbclib
$ yarn add js-bbclib
```

・From GitHub:
```$xslt
$ git clone https://github.com/t-hashimoto249/js-bbclib.git
```

# Usage
First, you set up bbccore(:9000) and bbc-app-rest(:3000) on localhost or anther node.

・Make, serialize and sign transaction.

```$xslt
import * as bbclib from 'js-bbclib.js'

//make transaction
let user = "4d48ba82dc8607c9";
let user_id = new Buffer(user, "hex");
let keypair = new bbclib.KeyPair();
keypair.generate(); // or keypair.set_key_pair(private_key, public_key)
let tx = await bbclib.helper.make_transaction(user_id, 1, 0, true); # return BBcTransaction

//sign and add signature in transaction
await bbclib.helper.sign_and_add_signature(tx, keypair)

//serialize transaction for bson
let bsonobj = await tx.serialize(false, true);

//insert transaction in BBc-1
let xhr = new XMLHttpRequest();
let ip = "127.0.0.1"
xhr.open('POST', 'http://' + ip + ':3000/insert_transaction/' + domain, false);
xhr.setRequestHeader('Content-Type', 'application/json');
let parameter = {
       'source_user_id': user1,
       'transaction_bson': bbclib.helper.Base64.encode(bsonobj)
};

xhr.addEventListener("load", function (event) {
    //get response from bbc-app-rest
    if( event.target.status == 200 || event.target.status == 304 ) {    
       
    }else{
       
    }
       
});
xhr.send(JSON.stringify(parameter));

```

・Search, deserialize and verify transaction.

```$xslt
import * as bbclib from 'js-bbclib.js'

//make transaction
let user = "4d48ba82dc8607c9";
let user_id = new Buffer(user, "hex");
let keypair = new bbclib.KeyPair();
keypair.generate(); // or keypair.set_key_pair(private_key, public_key)
let tx = await bbclib.helper.make_transaction(user_id, 1, 0, true); # return BBcTransaction

//sign and add signature in transaction
await bbclib.helper.sign_and_add_signature(tx, keypair)

//serialize transaction for bson
let bsonobj = await tx.serialize(false, true);

//insert transaction in BBc-1
let xhr = new XMLHttpRequest();
let ip = "127.0.0.1"
xhr.open('POST', 'http://' + ip + ':3000/insert_transaction/' + domain, false);
xhr.setRequestHeader('Content-Type', 'application/json');
let parameter = {
       'source_user_id': user1,
       'transaction_bson': bbclib.helper.Base64.encode(bsonobj)
};

xhr.addEventListener("load", function (event) {
    //get response from bbc-app-rest
    if( event.target.status == 200 || event.target.status == 304 ) {    
       
    }else{
       
    }
       
});
xhr.send(JSON.stringify(parameter));

```


# License
Licensed under the MIT license, see LICENSE file.

## keyword
BBc-1, Block-Chain,

---
_Source: https://npm.io/package/bbc1-simple-library · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
