npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

crowdnode

v1.8.0

Published

Manage your stake in Đash with the CrowdNode Blockchain API

Downloads

6

Readme

CrowdNode Node.js SDK

CrowdNode allows you to become a partial MNO - staking Dash to earn interest, participate in voting, etc.

The CrowdNode Node.js SDK enables you to build Web-based flows and cross-platform CLI tools to privately manage staking using CrowdNode's KYC-free Blockchain API.

Install

Node.js

You must have node.js installed:

Mac & Linux

curl https://webinstall.dev/node | bash
export PATH="${HOME}/.local/opt/node:$PATH"

Windows

curl.exe -A MS https://webinstall.dev/node | powershell
PATH %USERPROFILE%\.local\opt\node;%PATH%

CrowdNode SDK

npm install --save crowdnode@v1

CrowdNode Browser SDK

<script src="https://unpkg.com/@root/[email protected]/urequest.js"></script>
<script src="https://unpkg.com/[email protected]/dashrequest.js"></script>
<script src="https://unpkg.com/[email protected]/dashsight.js"></script>
<script src="https://unpkg.com/[email protected]/dashsocket.js"></script>
<script src="https://unpkg.com/@dashevo/[email protected]"></script>
<script src="https://unpkg.com/[email protected]/dashapi.js"></script>
<script src="https://unpkg.com/[email protected]/crowdnode.js"></script>
(async function () {
  let dashsight = window.DashSight.create({
    baseUrl: "https://insight.dash.org",
  });

  // ...

  await window.DashSocket.listen(
    "https://insight.dash.org",
    function finder(evname, data) {
      console.log(evname, data);
    },
    { debug: true },
  );
})();

API

The SDK also provides Type Hinting via JSDoc (compatible with TypeScript / tsc without any transpiling).

IMPORTANT

The CLI is denominated in Dash and Percent because those are the units most customers are familiar with and can easily calculate in their heads without making "careless" mistakes.

HOWEVER, the SDK and CrowdNode API are denominated in Duffs (Satoshis) and Permil (Permille) because those are the whole units that are easiest to compute.

QuickStart

The CrowdNode SDK uses Dashcore to create raw transactions and broadcasts them as Instant Send via the Dash Insight API. It uses Dash Insight WebSockets to listen for responses from the CrowdNode hotwallet.

A simple CrowdNode application may look like this:

"use strict";

let Fs = require("fs").promises;
let CrowdNode = require("crowdnode");

async function main() {
  let keyfile = process.argv[2];

  // a wallet pre-loaded with about Đ0.01
  let wif = await Fs.readFile(keyfile, "utf8");
  wif = wif.trim();

  // Initializes API info, such as hotwallets
  await CrowdNode.init({ insightBaseUrl: "https://insight.dash.org/" });

  let hotwallet = CrowdNode.main.hotwallet;
  await CrowdNode.signup(wif, hotwallet);
  await CrowdNode.accept(wif, hotwallet);
  await CrowdNode.deposit(wif, hotwallet);

  console.info("Congrats! You're staking!");
}

main().catch(function (err) {
  console.error("Fail:");
  console.error(err.stack || err);
  process.exit(1);
});

There are also a number of utility functions which are not exposed as public APIs, but which you could learn from in crowdnode-cli.

Constants

CrowdNode.offset = 20000;
CrowdNode.duffs = 100000000;
CrowdNode.depositMinimum = 10000;

CrowdNode.requests = {
  acceptTerms: 65536,
  offset: 20000,
  signupForApi: 131072,
  toggleInstantPayout: 4096,
  withdrawMin: 1,
  withdrawMax: 1000,
};

CrowdNode.responses = {
  PleaseAcceptTerms: 2,
  WelcomeToCrowdNodeBlockChainAPI: 4,
  DepositReceived: 8,
  WithdrawalQueued: 16,
  WithdrawalFailed: 32,
  AutoWithdrawalEnabled: 64,
  AutoWithdrawalDisabled: 128,
};

Usage

Manage Stake

await CrowdNode.init({ insightBaseUrl: "https://insight.dash.org" });

CrowdNode.main.baseUrl; // "https://app.crowdnode.io"
CrowdNode.main.hotwallet; // "XjbaGWaGnvEtuQAUoBgDxJWe8ZNv45upG2"

await CrowdNode.status(pubAddress, hotwallet);
/*
 * {
 *   signup: 0, // seconds since unix epoch
 *   accept: 0,
 *   deposit: 0,
 * }
 */

await CrowdNode.signup(wif, hotwallet);
/** @type SocketPayment
 * {
 *   "address": "Xj00000000000000000000000000000000",
 *   "satoshis": 20002, // PleaseAcceptTerms
 *   "timestamp": 1655634136000,
 *   "txid": "xxxx...",
 *   "txlock": true
 * }
 */

await CrowdNode.accept(wif, hotwallet);
/** @type SocketPayment
 * {
 *   "address": "Xj00000000000000000000000000000000",
 *   "satoshis": 20004, // WelcomeToCrowdNodeBlockChainAPI
 *   "timestamp": 1655634138000,
 *   "txid": "xxxx...",
 *   "txlock": true
 * }
 */

// amount given in DUFFs
await CrowdNode.deposit(wif, hotwallet, (amount = 0));
/** @type SocketPayment
 * {
 *   "address": "Xj00000000000000000000000000000000",
 *   "satoshis": 20008, // DepositReceived
 *   "timestamp": 1655634142000,
 *   "txid": "xxxx...",
 *   "txlock": true
 * }
 */

// permil is 1/10 percent, 500 permil = 50.0 percent
await CrowdNode.withdraw(wif, hotwallet, permil);
/** @type SocketPayment
 * {
 *   "address": "Xj00000000000000000000000000000000",
 *   "satoshis": 20016, // WithdrawalQueued
 *   "timestamp": 1657634142000,
 *   "txid": "xxxx...",
 *   "txlock": true
 * }
 */

HTTP RPC

await CrowdNode.http.GetBalance(pubAddr);
/** @type CrowdNodeBalance
 * {
 *   "DashAddress": "Xj00000000000000000000000000000000",
 *   "TotalBalance": 0.01292824,
 *   "TotalActiveBalance": 0,
 *   "TotalDividend": 0,
 *   "UpdatedOn": "2022-06-19T08:06:19.11",
 *   "UpdateOnUnixTime": 1655625979
 * }
 */

await CrowdNode.http.GetFunds(pubAddr);
await CrowdNode.http.GetFundsFrom(pubAddr, secondsSinceEpoch);
/*
 *  [
 *    {
 *      "FundingType": 1,
 *      "Amount": 0.00810218,
 *      "Time": 1655553336,
 *      "TimeReceived": 1655553336,
 *      "TxId": "e5a...",
 *      "Status": 32,
 *      "Comment": null,
 *      "TimeUTC": "2022-06-18T11:55:36",
 *      "Id": 3641556,
 *      "UpdatedOn": "2022-06-18T12:04:15.1233333"
 *    }
 *  ]
 */

await CrowdNode.http.IsAddressInUse(pubAddr);
/**
 * {
 *   "inUse": true,
 *   "DashAddress": "Xj00000000000000000000000000000000"
 * }
 */

Messages (Voting, etc)

await CrowdNode.http.GetMessages(pubAddr);
/**
 * []
 */

await CrowdNode.http.SetEmail(wif, email, sig);
await CrowdNode.http.Vote(wif, gobjectHash, vote, sig);
await CrowdNode.http.SetReferral(wif, referralId, sig);
await CrowdNode.http.FundsOpen(pub);
/* ${baseUrl}/FundsOpen/${pub} */

await CrowdNode.http.VotingOpen(pub);
/* ${baseUrl}/VotingOpen/${pub} */

Glossary

| Term | Description | | ------------- | ------------------------------------------------------------- | | addr | your Dash address (Base58Check-encoded Pay-to-PubKey Address) | | amount | the integer value of "Duffs" (Đ/100000000) | | permil | 1/1000, 1‰, or 0.1% - between 1 and 1000 (0.1% to 100.0%) | | ./privkey.wif | the file path to your staking key in WIF (Base58Check) format |

CLI Documentation

See https://github.com/dashhive/crowdnode-cli.

Official CrowdNode Docs

https://knowledge.crowdnode.io/en/articles/5963880-blockchain-api-guide