# crowdnode

> Manage your stake in Đash with the CrowdNode Blockchain API

Latest version **1.8.0** (published 2022-11-15) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

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

Provides the command `crowdnode`.

## 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 | 1.8.0 |
| Published | 2022-11-15 |
| First published | 2022-06-19 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 158.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | AJ ONeal |
| Maintainers | coolaj86 |
| Keywords | Dash, CrowdNode, Blockchain, Stake, Staking |

## Links

- npm: https://www.npmjs.com/package/crowdnode
- Repository: https://github.com/dashhive/crowdnode.js
- Homepage: https://github.com/dashhive/crowdnode.js#readme
- Issues: https://github.com/dashhive/crowdnode.js/issues
- npm.io page: https://npm.io/package/crowdnode

## Dependencies (7)

- [ws](https://npm.io/package/ws.md) ^8.8.0
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.1
- [dashsight](https://npm.io/package/dashsight.md) ^1.3.0-0
- [qrcode-svg](https://npm.io/package/qrcode-svg.md) ^1.1.0
- [tough-cookie](https://npm.io/package/tough-cookie.md) ^4.0.0
- [@root/request](https://npm.io/package/@root/request.md) ^1.9.1
- [@dashevo/dashcore-lib](https://npm.io/package/@dashevo/dashcore-lib.md) ^0.19.41

## 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

- 1.8.0 (latest) — 2022-11-15
- 1.7.0-2 (beta) — 2022-10-04
- 1.8.0-2 — 2022-11-13
- 1.8.0-1 — 2022-11-13
- 1.8.0-0 — 2022-11-13
- 1.7.0 — 2022-10-04
- 1.7.0-1 — 2022-10-04
- 1.7.0-0 — 2022-09-20
- 1.6.2 — 2022-08-24
- 1.6.1 — 2022-07-13
- 1.6.0 — 2022-07-04
- 1.5.1 — 2022-06-27
- 1.5.0 — 2022-06-25
- 1.4.0 — 2022-06-25
- 1.3.1 — 2022-06-23
- … 6 more at https://npm.io/package/crowdnode/versions

## README

# [CrowdNode Node.js SDK](https://github.com/dashhive/crowdnode.js)

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](https://webinstall.dev/node) installed:

### Mac & Linux

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

### Windows

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

## CrowdNode SDK

```bash
npm install --save crowdnode@v1
```

## CrowdNode Browser SDK

```html
<script src="https://unpkg.com/@root/request@1.x/urequest.js"></script>
<script src="https://unpkg.com/dashsight@1.x/dashrequest.js"></script>
<script src="https://unpkg.com/dashsight@1.x/dashsight.js"></script>
<script src="https://unpkg.com/dashsight@1.x/dashsocket.js"></script>
<script src="https://unpkg.com/@dashevo/dashcore-lib@0.19.x"></script>
<script src="https://unpkg.com/crowdnode@1.x/dashapi.js"></script>
<script src="https://unpkg.com/crowdnode@1.x/crowdnode.js"></script>
```

```js
(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:

```js
"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](/bin/crowdnode.js).

## Constants

```js
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

```js
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

```js
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)

```js
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);
```

```js
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>

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