# @dashevo/dashd-rpc

> Dash Client Library to connect to Dash Core (dashd) via RPC

Latest version **19.0.0** (published 2024-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dashevo/dashd-rpc
pnpm add @dashevo/dashd-rpc
yarn add @dashevo/dashd-rpc
bun add @dashevo/dashd-rpc
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 19.0.0 |
| Published | 2024-07-09 |
| First published | 2018-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 33.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Stephen Pair |
| Maintainers | shumkov, alex-werner, nmarley, cofresi, antouhou, evodeploy, jawid-h |
| Keywords | dash, rpc |

## Links

- npm: https://www.npmjs.com/package/@dashevo/dashd-rpc
- Repository: https://github.com/dashevo/dashd-rpc
- Issues: https://github.com/dashevo/dashd-rpc/issues
- npm.io page: https://npm.io/package/@dashevo/dashd-rpc

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^3.2.4
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 19.0.0 (latest) — 2024-07-09
- 18.3.0 — 2024-05-28
- 18.2.0 — 2022-12-30
- 18.0.2 — 2022-10-27
- 18.0.1 — 2022-09-22
- 18.0.0 — 2022-09-22
- 2.4.2 — 2022-09-16
- 2.4.1 — 2022-07-06
- 2.4.0 — 2022-06-30
- 2.3.2 — 2022-01-13
- 2.3.1 — 2021-09-26
- 2.3.0 — 2021-04-28
- 2.2.2 — 2021-03-25
- 2.2.1 — 2021-03-25
- 2.1.1 — 2021-03-02
- … 9 more at https://npm.io/package/@dashevo/dashd-rpc/versions

## README

# dashd-rpc

[![Build Status](https://github.com/dashevo/dashd-rpc/actions/workflows/test.yml/badge.svg)](https://github.com/dashevo/dashd-rpc/actions/workflows/test.yml)
[![NPM Package](https://img.shields.io/npm/v/@dashevo/dashd-rpc.svg)](https://www.npmjs.org/package/@dashevo/dashd-rpc)

Dash Client Library to connect to Dash Core (dashd) via RPC

## Install

dashd-rpc runs on [node](http://nodejs.org/), and can be installed via [npm](https://npmjs.org/):

```bash
npm install @dashevo/dashd-rpc
```

## Usage

### RpcClient

Config parameters : 

	- protocol : (string - optional) - (default: 'https') - Set the protocol to be used. Either `http` or `https`.
	- user : (string - optional) - (default: 'user') - Set the user credential.
	- pass : (string - optional) - (default: 'pass') - Set the password credential.
	- host : (string - optional) - (default: '127.0.0.1') - The host you want to connect with.
	- port : (integer - optional) - (default: 9998) - Set the port on which perform the RPC command.

Promise vs callback based

  - `require('@dashevo/dashd-rpc/promise')` to have promises returned
  - `require('@dashevo/dashd-rpc')` to have callback functions returned
	
### Examples

Config:

```javascript
var config = {
    protocol: 'http',
    user: 'dash',
    pass: 'local321',
    host: '127.0.0.1',
    port: 19998
};
```

Promise based:

```javascript
var RpcClient = require('@dashevo/dashd-rpc/promise');
var rpc = new RpcClient(config);

rpc.getRawMemPool()
    .then(ret => {
        return Promise.all(ret.result.map(r => rpc.getRawTransaction(r)))
    })
    .then(rawTxs => {
        rawTxs.forEach(rawTx => {
            console.log(`RawTX: ${rawTx.result}`);
        })
    })
    .catch(err => {
        console.log(err)
    })
```

Callback based (legacy):

```javascript
var run = function() {
  var bitcore = require('@dashevo/dashcore-lib');
  var RpcClient = require('@dashevo/dashd-rpc');
  var rpc = new RpcClient(config);

  var txids = [];

  function showNewTransactions() {
    rpc.getRawMemPool(function (err, ret) {
      if (err) {
        console.error(err);
        return setTimeout(showNewTransactions, 10000);
      }

      function batchCall() {
        ret.result.forEach(function (txid) {
          if (txids.indexOf(txid) === -1) {
            rpc.getRawTransaction(txid);
          }
        });
      }

      rpc.batch(batchCall, function(err, rawtxs) {
        if (err) {
          console.error(err);
          return setTimeout(showNewTransactions, 10000);
        }

        rawtxs.map(function (rawtx) {
          var tx = new bitcore.Transaction(rawtx.result);
          console.log('\n\n\n' + tx.id + ':', tx.toObject());
        });

        txids = ret.result;
        setTimeout(showNewTransactions, 2500);
      });
    });
  }

  showNewTransactions();
};
```

### Help

You can dynamically access to the help of each method by doing

```
const RpcClient = require('@dashevo/dashd-rpc');
var client = new RPCclient({
    protocol:'http',
    user: 'dash',
    pass: 'local321', 
    host: '127.0.0.1', 
    port: 19998,
    timeout: 1000
});

var cb = function (err, data) {
    console.log(data)
};

// Get full help
client.help(cb);

// Get help of specific method
client.help('getinfo',cb);
```

## Contributing

Feel free to dive in! [Open an issue](https://github.com/dashevo/dash-std-template/issues/new) or submit PRs.

## License

[MIT](LICENSE) &copy; Dash Core Group, Inc.

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