Javascript SDK for Dash Platform network that let you interact with the chain.
Does not support Core chain by design
It can be used to query network, create, sign and broadcast the transactions in any Javascript environment. It works both in Node.js, Browsers, and with modern frontend frameworks
SDK uses a pre-defined set of seed nodes (public RPC) at the start, and then tries to switch to the latest list of nodes from the network
Currently, only minimal features are included, such as document querying and creation of the documents, and all necessary related functions to do that There is no input validation and error handling implemented yet relying on a happy path, this is going to be fixed in next versions
React Native support
Dash Platform v3.0 support, improved codebase, better compatibility across different environments
Token support, Identity State Transitions (create, topup, update), Identity Public Keys management,
Dash Platform v2.0 support, improved codebase (more methods and typings)
First, PoC version, only documents creation / signing support
The SDK is isomorphic and works in both Node.js and web browsers without requiring polyfills. When using in browsers, make sure to include the library from CDN or bundle it with your application.
https://pshenmic.github.io/dash-platform-sdk/index.html
$ npm install dash-platform-sdk
Alternatively, you could simply include the library from the CDN:
https://unpkg.com/dash-platform-sdk/dist/main.js
To use the SDK, simply import the library and instantiate an instance of DashPlatformSDK:
// ES6 / EcmaScript
import {DashPlatformSDK} from 'dash-platform-sdk'
// CommonJS
const {DashPlatformSDK} = require('dash-platform-sdk')
const sdk = new DashPlatformSDK({network: 'testnet'})
Or load it straight from the web page:
<script src="https://unpkg.com/dash-platform-sdk/bundle.min.js"></script>
<script>
const {DashPlatformSDK} = window.DashPlatformSDK
const sdk = new DashPlatformSDK.DashPlatformSDK({network: 'testnet'})
</script>
Now you're ready to make queries in the network and push your data!
See docs/Quickstart.md for basic usage examples (register data contract, push/update/delete documents).
The full autogenerated typedoc reference is available at https://pshenmic.github.io/dash-platform-sdk/index.html
The SDK currently relies on a happy path and doesn't include comprehensive error handling. This will be improved in future versions. For now, wrap SDK calls in try-catch blocks:
try {
const identity = await sdk.identities.getIdentityByIdentifier('invalid-id')
} catch (error) {
console.error('Failed to fetch identity:', error)
}
The folder docs/examples in this repo contains useful example code snippets.
| Quickstart.md | Install, Import, Register Data Contract, Push / Update / Delete Document |
| DataContracts.md | Get Data Contract By Identifier, Create Data Contract, Create State Transition |
| Documents.md | Create Document, Query Documents, Create State Transition (Create / Replace/ Delete / Transfer / Purchase / UpdatePrice) |
| Tokens.md | Get Balance, Get Contract Info, Get Supply, Get prices, Create State Transition |
| Identities.md | Get Identity, Get Identity Balance, Get Identity Nonce, Get Identity Public Keys, Create Identity (from AssetLockProof), Top Up Identity (from AssetLockProof), Update Identity, Credit Transfer, Credit Withdrawal |
| Voting.md | Casting Masternode Vote against Contested Resource |
| StateTransitions.md | Broadcast Transaction, Wait for State Transition Result (wait for finalization) |
| Names.md | Search By Dash Username (DPNS Name), Search by Identity's Identifier, Register Dash Username (DPNS Name), Test Name Contested (validation), Validate Name (validation) |
| Node.md | Node Status, Total Credits (locked in Platform), Epochs Info |
| Utils.md | useful utility functions, like hex/base58 encoding, createVoterIdentifier, createMasternodeIdentifier, validateIdentifier |
| KeyPair.md | Mnemonic to Seed, Seed to HD Key, Derive Identity Private Key, Derive Child, Derive Path, P2PKH Address conversion |
| ContestedResources.md | Contested Resource Vote State Info |