1 # CrowdNode Node.js SDK
3 CrowdNode allows you to become a partial MNO - staking Dash to earn interest,
4 participate in voting, etc.
6 The CrowdNode Node.js SDK enables you to build Web-based flows and
7 cross-platform CLI tools to privately manage staking using CrowdNode's KYC-free
14 You must have [node.js](https://webinstall.dev/node) installed:
18 curl https://webinstall.dev/node | bash
19 export PATH="${HOME}/.local/opt/node:$PATH"
24 curl.exe -A MS https://webinstall.dev/node | powershell
25 PATH %USERPROFILE%\.local\opt\node;%PATH%
31 npm install --save crowdnode@v1
36 The SDK also provides Type Hinting via JSDoc (compatible with TypeScript / tsc
37 without any transpiling).
41 The CrowdNode SDK uses Dashcore to create raw transactions and broadcasts them
42 as Instant Send via the Dash Insight API. It uses Dash Insight WebSockets to
43 listen for responses from the CrowdNode hotwallet.
45 A simple CrowdNode application may look like this:
50 let Fs = require("fs").promises;
51 let CrowdNode = require("crowdnode");
53 async function main() {
54 let keyfile = process.argv[2];
56 // a wallet pre-loaded with about Đ0.001
57 let wif = await Fs.readFile(keyfile, "utf8");
60 // Initializes API info, such as hotwallets
61 await CrowdNode.init({ insightBaseUrl: "https://insight.dash.org/" });
63 let hotwallet = CrowdNode.main.hotwallet;
64 await CrowdNode.signup(wif, hotwallet);
65 await CrowdNode.accept(wif, hotwallet);
66 await CrowdNode.deposit(wif, hotwallet);
68 console.info("Congrats! You're staking!");
71 main().catch(function (err) {
72 console.error("Fail:");
73 console.error(err.stack || err);
78 There are also a number of utility functions which are not exposed as public
79 APIs, but which you could learn from in [crowdnode-cli](/bin/crowdnode.js).
84 CrowdNode.offset = 20000;
85 CrowdNode.duffs = 100000000;
86 CrowdNode.depositMinimum = 10000;
88 CrowdNode.requests = {
92 toggleInstantPayout: 4096,
97 CrowdNode.responses = {
99 WelcomeToCrowdNodeBlockChainAPI: 4,
101 WithdrawalQueued: 16,
102 WithdrawalFailed: 32,
103 AutoWithdrawalEnabled: 64,
104 AutoWithdrawalDisabled: 128,
113 await CrowdNode.init({ insightBaseUrl: "https://insight.dash.org" });
115 CrowdNode.main.baseUrl; // "https://app.crowdnode.io"
116 CrowdNode.main.hotwallet; // "XjbaGWaGnvEtuQAUoBgDxJWe8ZNv45upG2"
118 await CrowdNode.status(pubAddress, hotwallet);
121 * signup: 0, // seconds since unix epoch
127 await CrowdNode.signup(wif, hotwallet);
128 /** @type SocketPayment
130 * "address": "Xj00000000000000000000000000000000",
131 * "satoshis": 20002, // PleaseAcceptTerms
132 * "timestamp": 1655634136000,
138 await CrowdNode.accept(wif, hotwallet);
139 /** @type SocketPayment
141 * "address": "Xj00000000000000000000000000000000",
142 * "satoshis": 20004, // WelcomeToCrowdNodeBlockChainAPI
143 * "timestamp": 1655634138000,
149 await CrowdNode.deposit(wif, hotwallet, (amount = 0));
150 /** @type SocketPayment
152 * "address": "Xj00000000000000000000000000000000",
153 * "satoshis": 20008, // DepositReceived
154 * "timestamp": 1655634142000,
160 await CrowdNode.withdrawal(wif, hotwallet, permil);
161 /** @type SocketPayment
163 * "address": "Xj00000000000000000000000000000000",
164 * "satoshis": 20016, // WithdrawalQueued
165 * "timestamp": 1657634142000,
175 await CrowdNode.http.GetBalance(pubAddr);
176 /** @type CrowdNodeBalance
178 * "DashAddress": "Xj00000000000000000000000000000000",
179 * "TotalBalance": 0.01292824,
180 * "TotalActiveBalance": 0,
181 * "TotalDividend": 0,
182 * "UpdatedOn": "2022-06-19T08:06:19.11",
183 * "UpdateOnUnixTime": 1655625979
187 await CrowdNode.http.GetFunds(pubAddr);
188 await CrowdNode.http.GetFundsFrom(pubAddr, secondsSinceEpoch);
193 * "Amount": 0.00810218,
194 * "Time": 1655553336,
195 * "TimeReceived": 1655553336,
199 * "TimeUTC": "2022-06-18T11:55:36",
201 * "UpdatedOn": "2022-06-18T12:04:15.1233333"
206 await CrowdNode.http.IsAddressInUse(pubAddr);
210 * "DashAddress": "Xj00000000000000000000000000000000"
215 ### Messages (Voting, etc)
218 await CrowdNode.http.GetMessages(pubAddr);
223 await CrowdNode.http.SetEmail(wif, email, sig);
224 await CrowdNode.http.Vote(wif, gobjectHash, vote, sig);
225 await CrowdNode.http.SetReferral(wif, referralId, sig);
229 await CrowdNode.http.FundsOpen(pub);
230 /* ${baseUrl}/FundsOpen/${pub} */
232 await CrowdNode.http.VotingOpen(pub);
233 /* ${baseUrl}/VotingOpen/${pub} */
238 See <https://github.com/dashhive/crowdnode.js/tree/main/cli>.
240 # Official CrowdNode Docs
242 <https://knowledge.crowdnode.io/en/articles/5963880-blockchain-api-guide>