Skip to content

About

A lightweight Javascript Dash Platform SDK

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

dash-platform-sdk v1.5.3

GitHub license npm version a

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

Features

  • Cryptographic proofs for DAPI (GRPC) queries
  • Create, Sign, and Broadcast Dash Platform (Dash Evolution) transactions
  • Rich API compatible with ESNext
  • Isomorphic library (works in Web and Node.js environments)
  • Autogenerated documentation

Versioning

v1.6.x (next)

Identity Shielded Token transfer

v1.5.x (current)

React Native support, shielded transitions support

v1.4.x

Node API support

v1.3.x

Dash Platform v3.0 support, improved codebase, better compatibility across different environments

v1.2.x

Token support, Identity State Transitions (create, topup, update), Identity Public Keys management,

v1.1.x

Dash Platform v2.0 support, improved codebase (more methods and typings)

v1.0.x

First, PoC version, only documents creation / signing support

Browser 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.

Documentation

https://pshenmic.github.io/dash-platform-sdk/index.html

Quickstart

Install

$ npm install dash-platform-sdk

Alternatively, you could simply include the library from the CDN:

https://unpkg.com/dash-platform-sdk/dist/main.js

Import

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).

API Documentation

The full autogenerated typedoc reference is available at https://pshenmic.github.io/dash-platform-sdk/index.html

Error Handling

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)
}

Examples

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
PlatformAddresses.md Get Address Info, Create State Transition, Convenience builders (Transfer To Address, Create / Top Up Identity From Addresses, Transfer Between Addresses, Fund From Asset Lock, Withdrawal To Core)

About

A lightweight Javascript Dash Platform SDK

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages