All Projects → dashevo → dashd-rpc

dashevo / dashd-rpc

Licence: MIT license
Dash Client Library to connect to Dash Core (dashd) via RPC

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to dashd-rpc

Concourse
Distributed database warehouse for transactions, search and analytics across time.
Stars: ✭ 310 (+1723.53%)
Mutual labels:  platform, backend
October
Self-hosted CMS platform based on the Laravel PHP Framework.
Stars: ✭ 10,740 (+63076.47%)
Mutual labels:  platform, backend
dashcore-node
Full node with extended capabilities using Dashcore and Dash Core (dashd)
Stars: ✭ 30 (+76.47%)
Mutual labels:  platform, dapi
matters-web
Website of Matters.News, built with Next.js.
Stars: ✭ 70 (+311.76%)
Mutual labels:  platform
kotlin-no-backend
Lista de empresas que utilizam Kotlin no Brasil.
Stars: ✭ 46 (+170.59%)
Mutual labels:  backend
kratix
Kratix is a framework for building Platform-as-a-Product
Stars: ✭ 175 (+929.41%)
Mutual labels:  platform
nestjs-zero-to-hero
Coding through the course: NestJS Zero to Hero - Modern TypeScript Backend Development
Stars: ✭ 23 (+35.29%)
Mutual labels:  backend
appng
appNG is an open source, horizontally scalable application platform for developing and operating applications efficiently. It can be used to build an Application Platform as a Service (aPaaS).
Stars: ✭ 32 (+88.24%)
Mutual labels:  platform
typed-ajv
Define TypeScript types and JSON Schema schemas from the same declarations
Stars: ✭ 18 (+5.88%)
Mutual labels:  backend
foss-events
A simple website with a collection of open-source events happening across the globe. This is a beginner-friendly repository that helps you learn git and contribute to web projects. Happy Hacktober!
Stars: ✭ 123 (+623.53%)
Mutual labels:  backend
trampolim
A modern Python build backend
Stars: ✭ 39 (+129.41%)
Mutual labels:  backend
todo
An example todo application with Go!
Stars: ✭ 61 (+258.82%)
Mutual labels:  backend
backend-server
📠 The backend of the Fairfield Programming Association website.
Stars: ✭ 26 (+52.94%)
Mutual labels:  backend
platframe
Structured, scalable and modular frontend development platform.
Stars: ✭ 38 (+123.53%)
Mutual labels:  platform
kasir
Cashier Management & Inventory Management System
Stars: ✭ 28 (+64.71%)
Mutual labels:  backend
solr
Apache Solr open-source search software
Stars: ✭ 651 (+3729.41%)
Mutual labels:  backend
be-the-hero-omnistack-11
Semana OmniStack 11 - Be The Hero [possui alterações pessoais]
Stars: ✭ 14 (-17.65%)
Mutual labels:  backend
gae-vue-webapp2-starter
A simple GAE Vue Webapp2 starter project.
Stars: ✭ 17 (+0%)
Mutual labels:  backend
awesome-coder-resources
编程路上加油站!------【持续更新中...欢迎star,欢迎常回来看看......】【内容:编程/学习/阅读资源,开源项目,面试题,网站,书,博客,教程等等】
Stars: ✭ 54 (+217.65%)
Mutual labels:  backend
Pharmacy-Mangment-System
👨‍💻 🏥 MEAN stack Pharmacy Management system.
Stars: ✭ 229 (+1247.06%)
Mutual labels:  backend

dashd-rpc

Build Status 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 @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:

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

Promise based:

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):

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 or submit PRs.

License

MIT © Dash Core Group, Inc.

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].