Dash SDK
Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)
Dash library provides access via DAPI to use both the Dash Core network and Dash Platform on supported networks. The Dash Core network can be used to broadcast and receive payments. Dash Platform can be used to manage identities, register data contracts for applications, and submit or retrieve application data via documents.
Table of Contents
Install
ES5/ES6 via NPM
In order to use this library, you will need to add it to your project as a dependency.
Having NodeJS installed, just type : npm install dash
in your terminal.
npm install dash
CDN Standalone
For browser usage, you can also directly rely on unpkg :
<script src="https://unpkg.com/dash"></script>
Usage
const Dash = require("dash");
const client = new Dash.Client({
wallet: {
mnemonic: "arena light cheap control apple buffalo indicate rare motor valid accident isolate",
},
apps: {
tutorialContract: {
contractId: "<tutorial-contract-id>"
}
}
});
client.wallet.getAccount().then(async (account) => {
console.log('Funding address', account.getUnusedAddress().address);
const balance = account.getConfirmedBalance();
console.log('Confirmed Balance', balance);
if (balance > 0) {
const identityIds = account.identities.getIdentityIds();
const identity = await client.platform.identities.get(identityIds[0]);
const document = await client.platform.documents.create(
'tutorialContract.note',
identity,
{ message: 'Hello World' },
);
await client.platform.documents.broadcast({ create: [document] }, identity);
const documents = await client.platform.documents.get('tutorialContract.note', {
limit: 2,
});
console.log(documents);
}
});
Primitives and essentials
Dash SDK bundled into a standalone package,
so that the end user never have to worry about mananaging polyfills or related dependencies
const Dash = require('dash')
const {
Essentials: {
Buffer
},
Core: {
Transaction,
PrivateKey,
BlockHeader,
},
PlatformProtocol: {
Identity,
Identifier,
},
WalletLib: {
EVENTS
},
DAPIClient,
} = Dash;
Dependencies
The Dash SDK works using multiple dependencies that might interest you:
- Wallet-Lib - Wallet management for handling, signing and broadcasting transactions (BIP-44 HD).
- Dashcore-Lib - Provides the main L1 blockchain primitives (Block, Transaction,...).
- DAPI-Client - Client library for accessing DAPI endpoints.
- Wasm-DPP - Implementation of Dash Platform Protocol.
Some features might be more extensive in those libs, as Dash SDK only wraps around them to provide a single interface that is easy to use (and thus has less features).
Documentation
More extensive documentation available at https://dashpay.github.io/platform/SDK/.
Contributing
Feel free to dive in! Open an issue or submit PRs.
License
MIT © Dash Core Group, Inc.