All Projects → bitshares → Bitsharesjs

bitshares / Bitsharesjs

Licence: mit
JavaScript tools for BitShares Encryption and Serialization

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Bitsharesjs

Istanbul Tools
Istanbul BFT tools
Stars: ✭ 80 (-9.09%)
Mutual labels:  blockchain
Copernicus
An alternative implementation of the Bitcoin Cash protocol, written in Golang
Stars: ✭ 83 (-5.68%)
Mutual labels:  blockchain
Solana Web3.js
Solana JavaScript SDK
Stars: ✭ 85 (-3.41%)
Mutual labels:  blockchain
Blockchain Real Estate
🚀基于区块链的房地产交易系统小模型。提供销售和捐赠功能。本项目使用Hyperledger Fabric构建区块链网络, go编写智能合约,应用层使用gin+fabric-sdk-go调用合约。前端展示使用vue+element。体验地址:http://blockchain.togettoyou.com/web
Stars: ✭ 81 (-7.95%)
Mutual labels:  blockchain
Whale
🐋 Show Ethereum and Bitcoin price in command line interface (CLI).
Stars: ✭ 81 (-7.95%)
Mutual labels:  blockchain
Chaingear
The consensus computer driven database framework
Stars: ✭ 83 (-5.68%)
Mutual labels:  blockchain
Bottos
public blockchain
Stars: ✭ 80 (-9.09%)
Mutual labels:  blockchain
Awesome Privacy On Blockchains
A curated list of privacy on blockchains resources
Stars: ✭ 86 (-2.27%)
Mutual labels:  blockchain
Iroha Ios
iOS Swift library for Iroha, a simple distributed ledger
Stars: ✭ 81 (-7.95%)
Mutual labels:  blockchain
Elementsproject.org
Source code for the ElementsProject.org website
Stars: ✭ 84 (-4.55%)
Mutual labels:  blockchain
Lisk Core
📟 Lisk blockchain application platform
Stars: ✭ 79 (-10.23%)
Mutual labels:  blockchain
Iroha Python
Python library for Hyperledger Iroha, a simple distributed ledger.
Stars: ✭ 81 (-7.95%)
Mutual labels:  blockchain
Blockchain Parser
The simpliest script for parsing Bitcoin blockchain. It made convertion of blk*****.dat files to the simple text.
Stars: ✭ 84 (-4.55%)
Mutual labels:  blockchain
Trust Wallet Ios
📱 Trust - Ethereum Wallet and Web3 DApp Browser for iOS
Stars: ✭ 1,228 (+1295.45%)
Mutual labels:  blockchain
Blockchain Kotlin
这是kotlin版的简化示例区块链demo;另外还有java版的;这个小demo能让你了解区块链中增加/效验Hash,增加工作量证明,增加/效验preHash,转账,利用webSocket技术实现节点之间的通信/同步/广播.
Stars: ✭ 85 (-3.41%)
Mutual labels:  blockchain
Neb.js
Stars: ✭ 80 (-9.09%)
Mutual labels:  blockchain
Stellarexplorer
Ledger Explorer for the Stellar Network 🚀
Stars: ✭ 82 (-6.82%)
Mutual labels:  blockchain
Blockchaintechnology
Blockchain Frontier Technology Tracking
Stars: ✭ 88 (+0%)
Mutual labels:  blockchain
Purple
Official Rust implementation of the Purple Protocol
Stars: ✭ 85 (-3.41%)
Mutual labels:  blockchain
Clutter
Fully distributed twitter built on holochain
Stars: ✭ 84 (-4.55%)
Mutual labels:  blockchain

BitsharesJS (bitsharesjs)

Pure JavaScript Bitshares library for node.js and browsers. Can be used to construct, sign and broadcast transactions in JavaScript, and to easily obtain data from the blockchain via public apis.

Most of this code was written by jcalfee, my work was mostly just repackaging to a discrete npm package.

npm version npm downloads

Security issues might be eligible for a bounty through the HackTheDex program.

Setup

This library can be obtained through npm:

npm install bitsharesjs

Usage

Three sub-libraries are included: ECC, Chain and Serializer. Generally only the ECC and Chain libraries need to be used directly.

Chain

This library provides utility functions to handle blockchain state as well as a login class that can be used for simple login functionality using a specific key seed.

Login

The login class uses the following format for keys:

keySeed = accountName + role + password

Using this seed, private keys are generated for either the default roles active, owner, memo, or as specified. A minimum password length of 12 characters is enforced, but an even longer password is recommended. Three methods are provided:

generateKeys(account, password, [roles])
checkKeys(account, password, auths)
signTransaction(tr)

The auths object should contain the auth arrays from the account object. An example is this:

{
    active: [
        ["GPH5Abm5dCdy3hJ1C5ckXkqUH2Me7dXqi9Y7yjn9ACaiSJ9h8r8mL", 1]
    ]
}

If checkKeys is successful, you can use signTransaction to sign a TransactionBuilder transaction using the private keys for that account.

State container

The Chain library contains a complete state container called the ChainStore. The ChainStore will automatically configure the set_subscribe_callback and handle any incoming state changes appropriately. It uses Immutable.js for storing the state, so all objects are return as immutable objects. It has its own subscribe method that can be used to register a callback that will be called whenever a state change happens.

The ChainStore has several useful methods to retrieve, among other things, objects, assets and accounts using either object ids or asset/account names. These methods are synchronous and will return undefined to indicate fetching in progress, and null to indicate that the object does not exist.

import {Apis} from "bitsharesjs-ws";
var {ChainStore} = require("bitsharesjs");

Apis.instance("wss://eu.nodes.bitshares.ws", true).init_promise.then((res) => {
    console.log("connected to:", res[0].network);
    ChainStore.init().then(() => {
        ChainStore.subscribe(updateState);
    });
});

let dynamicGlobal = null;
function updateState(object) {
    dynamicGlobal = ChainStore.getObject("2.1.0");
    console.log("ChainStore object update\n", dynamicGlobal ? dynamicGlobal.toJS() : dynamicGlobal);
}

ECC

The ECC library contains all the crypto functions for private and public keys as well as transaction creation/signing.

Private keys

As a quick example, here's how to generate a new private key from a seed (a brainkey for example):

var {PrivateKey, key} = require("bitsharesjs");

let seed = "THIS IS A TERRIBLE BRAINKEY SEED WORD SEQUENCE";
let pkey = PrivateKey.fromSeed( key.normalize_brainKey(seed) );

console.log("\nPrivate key:", pkey.toWif());
console.log("Public key :", pkey.toPublicKey().toString(), "\n");

Transactions

TODO transaction signing example

ESDoc (beta)

npm i -g esdoc esdoc-es7-plugin
esdoc -c ./esdoc.json
open out/esdoc/index.html

Binaries / Browserified bundles

Please have a look here to find your desired release. If you want to build the binaries yourself you can clone this repository and run npm install. It will create

  • Browserified version build/bitsharesjs.js
  • Browserified and minified (babel) version build/bitsharesjs.min.js
  • CommonJS version using webpack build/bitsharesjs.cjs
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].