# shardbit

> Communicate with shardbitd via JSON-RPC

Latest version **0.1.0** (published 2018-08-20) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install shardbit
pnpm add shardbit
yarn add shardbit
bun add shardbit
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-08-20 |
| First published | 2018-08-20 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 0 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Bill Casarin |
| Maintainers | shardbit-project |
| Keywords | shardbit, rpc |

## Links

- npm: https://www.npmjs.com/package/shardbit
- Repository: https://github.com/shardbit-project/node-shardbit
- Homepage: https://github.com/shardbit-project/node-shardbit#readme
- Issues: https://github.com/shardbit-project/node-shardbit/issues
- npm.io page: https://npm.io/package/shardbit

## Recent versions

- 0.1.0 (latest) — 2018-08-20

## README

# node-shardbit
[![npm][npm-image]][npm-url]
[![downloads][downloads-image]][downloads-url]

[npm-image]: https://img.shields.io/npm/v/shardbit.svg?style=flat
[npm-url]: https://npmjs.org/package/shardbit

[downloads-image]: https://img.shields.io/npm/dm/shardbit.svg?style=flat
[downloads-url]: https://npmjs.org/package/shardbit

node-shardbit is a simple wrapper for the ShardBit client's JSON-RPC API.

## Install

`npm install shardbit`

## Examples

### Create client

```js
// all config options are optional
var client = new shardbit.Client({
  host: 'localhost',
  port: 37452,
  user: 'username',
  pass: 'password',
  timeout: 30000
});
```

### Get balance across all accounts with minimum confirmations of 6

```js
client.getBalance('*', 6, function(err, balance, resHeaders) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});
```

### Getting the balance directly using `cmd`

```js
client.cmd('getbalance', '*', 6, function(err, balance, resHeaders){
  if (err) return console.log(err);
  console.log('Balance:', balance);
});
```

### Batch multiple RPC calls into single HTTP request

```js
var batch = [];
for (var i = 0; i < 10; ++i) {
  batch.push({
    method: 'getnewaddress',
    params: ['myaccount']
  });
}
client.cmd(batch, function(err, address, resHeaders) {
  if (err) return console.log(err);
  console.log('Address:', address);
});
```

## SSL
See [Enabling SSL on original client](https://en.shardbit.it/wiki/Enabling_SSL_on_original_client_daemon).

If you're using this to connect to shardbitd across a network it is highly
recommended to enable `ssl`, otherwise an attacker may intercept your RPC credentials
resulting in theft of your shardbits.

When enabling `ssl` by setting the configuration option to `true`, the `sslStrict`
option (verifies the server certificate) will also be enabled by default. It is
highly recommended to specify the `sslCa` as well, even if your shardbitd has
a certificate signed by an actual CA, to ensure you are connecting
to your own shardbitd.

```js
var client = new shardbit.Client({
  host: 'localhost',
  port: 37452,
  user: 'username',
  pass: 'password',
  ssl: true,
  sslStrict: true,
  sslCa: fs.readFileSync(__dirname + '/myca.cert')
});
```

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