Socket
Socket
Sign inDemoInstall

dashrpc

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

dashrpc

Lightweight JavaScript SDK Dash RPC, made Browser, Node.js, & Bundler compatible


Version published
Weekly downloads
42
decreased by-33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

DashRPC.js

NPM Package

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

Install

dashd-rpc runs on node, and can be installed via npm:

npm install --save dashrpc

Usage

You can examine RpcClient.callspec to see the list of supported RPCs:

console.info('Supported RPCs:');
console.info(RpcClient.callspec);

If any of them are out of date with Dash: Docs: RPCs: Quick Reference, feel free to open an issue or PR.

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.

Examples

Config:

var config = {
  protocol: 'http',
  user: 'dash',
  pass: 'local321',
  host: '127.0.0.1',
  port: 19998,
  onconnected: function () {
    console.info('[dashrpc] connected to `${config.host:config.port}`');
  },
};
var RpcClient = require('dashrpc');
var rpc = new RpcClient(config);

async function main() {
  let height = await rpc.init({ retry: 5000 });
  console.info(`[dashrpc] best block height is ${height}`);

  let rawMempool = await rpc.getRawMemPool();
  for (let result of rawMempool.result) {
    let rawTx = await rpc.getRawTransaction(r);
    console.info(`RawTX: ${rawTx.result}`);
  }
}

main
  .then(function () {
    process.exit(0);
  })
  .catch(function (err) {
    console.error(err);
    process.exit(1);
  });

Help

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

const RpcClient = require('dashrpc');
var client = new RPCclient({
    protocol:'http',
    user: 'dash',
    pass: 'local321',
    host: '127.0.0.1',
    port: 19998,
    timeout: 1000
});

// Get full help
{
    let help = client.help();
    console.log(help)
}

// Get help of specific method
{
    let getinfoHelp = client.help('getinfo');
    console.log(getinfoHelp)
}

License

This was originally forked from https://github.com/dashpay/dashd-rpc, but has since become its own project.

© 2024-Present Dash Incubator
© 2013-2022 Dash Core Group, Inc.

MIT

Keywords

FAQs

Package last updated on 12 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc