Dash Platform WASM JS SDK Documentation
Overview
The Dash Platform WASM JS SDK provides a WebAssembly-based interface for interacting with the Dash Platform from JavaScript and TypeScript applications. This documentation covers all available queries and state transitions.
Key Concepts
- Queries: Read-only operations that fetch data from the platform
- State Transitions: Write operations that modify state on the platform
- Proofs: Cryptographic proofs can be requested for most queries to verify data authenticity
- Credits: The platform's unit of account for paying transaction fees
- Default Limits: All queries with optional limit parameters default to a maximum of 100 items if not specified
Note: All examples below can be run directly in your browser using the testnet. Click the "Run" button to execute any example.
5DbLwAxGBzUzo81VewMUwn4b5P4bpv9FNFybi25XB5Bk
This is a known identity with activity on testnet that you can use for testing.
Queries
Identity Queries
Get Identity
Fetch an identity by its identifier
Parameters:
Example
Get Identity Keys
Retrieve keys associated with an identity
Parameters:
Options: All Keys (AllKeys {}) - Get all keys for the identity, Specific Keys (SpecificKeys with key_ids) - Get specific keys by ID [🚧 Work in Progress], Search Keys (SearchKey with purpose_map) - Search by purpose and security level [🚧 Work in Progress]
Example: 0,1,2
Example: {"0": {"0": "current"}, "1": {"0": "all"}}
Default: 100 (maximum items returned if not specified)
Example
Example 2 - Get Specific Keys
Example 3 - Search Keys by Purpose
Get Identities Contract Keys
Get keys for multiple identities related to a specific contract
Parameters:
Options: Authentication, Encryption, Decryption, Transfer, Voting
Example
Get Identity Nonce
Get the current nonce for an identity
Parameters:
Example
Get Identity Contract Nonce
Get the nonce for an identity in relation to a specific contract
Parameters:
Example
Get Identity Balance
Get the credit balance of an identity
Parameters:
Example
Get Identities Balances
Get balances for multiple identities
Parameters:
Example
Get Identity Balance and Revision
Get both balance and revision number for an identity
Parameters:
Example
Get Identity by Unique Public Key Hash
Find an identity by its unique public key hash
Parameters:
Example: b7e904ce25ed97594e72f7af0e66f298031c1754
Example
Get Identity by Non-Unique Public Key Hash
Find identities by non-unique public key hash
Parameters:
Example: 518038dc858461bcee90478fd994bba8057b7531
Example
Get Identity Token Balances
Get token balances for an identity
Parameters:
Example
Get Identities Token Balances
Get token balance for multiple identities
Parameters:
Example: Hqyu8WcRwXCTwbNxdga4CN5gsVEGc67wng4TFzceyLUv
Example
Get Identity Token Info
Get token information for an identity's tokens
Parameters:
Example: ["Hqyu8WcRwXCTwbNxdga4CN5gsVEGc67wng4TFzceyLUv"]
Default: 100 (maximum items returned if not specified)
Example
Get Identities Token Info
Get token information for multiple identities with a specific token
Parameters:
Example: Hqyu8WcRwXCTwbNxdga4CN5gsVEGc67wng4TFzceyLUv
Example
Data Contract Queries
Get Data Contract
Fetch a data contract by its identifier
Parameters:
Example: GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec
Example
Get Data Contract History
Get the version history of a data contract
Parameters:
Example: HLY575cNazmc5824FxqaEMEBuzFeE4a98GDRNKbyJqCM
Default: 100 (maximum items returned if not specified)
Example
Get Data Contracts
Fetch multiple data contracts by their identifiers
Parameters:
Example: ["GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec", "ALybvzfcCwMs7sinDwmtumw17NneuW7RgFtFHgjKmF3A"]
Example
Document Queries
Get Documents
Query documents from a data contract
Parameters:
Example: GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec
Example: domain
Example: [["normalizedParentDomainName", "==", "dash"], ["normalizedLabel", "==", "therea1s11mshaddy5"]]
Example: [["$createdAt", "desc"]]
Default: 100 (maximum items returned if not specified)
Example
Get Document
Fetch a specific document by ID
Parameters:
Example: GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec
Example: domain
Example: 7NYmEKQsYtniQRUmxwdPGeVcirMoPh5ZPyAKz8BWFy3r
Example
DPNS Queries
Get DPNS Usernames
Get DPNS usernames for an identity
Parameters:
Example
DPNS Check Availability
Check if a DPNS username is available
Parameters:
Example
DPNS Resolve Name
Resolve a DPNS name to an identity ID
Parameters:
Example
DPNS Search Name
Search for DPNS names that start with a given prefix
Parameters:
Example: Enter prefix (e.g., ali)
Example: Default: 10
Example
Voting & Contested Resources
Get Contested Resources
Get list of contested resources
Parameters:
Default: 100 (maximum items returned if not specified)
Example
Get Contested Resource Vote State
Get the current vote state for a contested resource
Parameters:
Example: ["dash", "alice"]
Example
Get Contested Resource Voters for Identity
Get voters who voted for a specific identity in a contested resource
Parameters:
Example: ["dash", "alice"]
Example: Default: 100
Example
Get Contested Resource Identity Votes
Get all votes cast by a specific identity
Parameters:
Default: 100 (maximum items returned if not specified)
Example
Get Vote Polls by End Date
Get vote polls within a time range
Parameters:
Example: Timestamp in milliseconds as string (e.g., 1650000000000)
Example: Timestamp in milliseconds as string (e.g., 1650086400000)
Default: 100 (maximum items returned if not specified)
Example
Protocol & Version
Get Protocol Version Upgrade State
Get the current state of protocol version upgrades
Parameters:
No parameters required
Example
Get Protocol Version Upgrade Vote Status
Get voting status for protocol version upgrades
Parameters:
Example: 143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113
Example
Epoch & Block
Get Epochs Info
Get information about epochs
Parameters:
Example
Get Current Epoch
Get information about the current epoch
Parameters:
No parameters required
Example
Get Finalized Epoch Info
Get information about finalized epochs
Parameters:
Example
Get Evonodes Proposed Epoch Blocks by IDs
Get proposed blocks by evonode IDs
Parameters:
Example: ["143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113"]
Example
Get Evonodes Proposed Epoch Blocks by Range
Get proposed blocks by range
Parameters:
Default: 100 (maximum items returned if not specified)
Example: 143dcd6a6b7684fde01e88a10e5d65de9a29244c5ecd586d14a342657025f113
Example
Token Queries
Get Token Statuses
Get token statuses
Parameters:
Example
Get Token Direct Purchase Prices
Get direct purchase prices for tokens
Parameters:
Example
Get Token Contract Info
Get information about a token contract
Parameters:
Example: EETVvWgohFDKtbB3ejEzBcDRMNYkc9TtgXY6y8hzP3Ta
Example
Get Token Perpetual Distribution Last Claim
Get last claim information for perpetual distribution
Parameters:
Example
Get Token Total Supply
Get total supply of a token
Parameters:
Example: Hqyu8WcRwXCTwbNxdga4CN5gsVEGc67wng4TFzceyLUv
Example
Group Queries
Get Group Info
Get information about a group
Parameters:
Example
Get Group Infos
Get information about multiple groups
Parameters:
Example
Get Group Actions
Get actions for a group
Parameters:
Options: Active, Closed
Example
Get Group Action Signers
Get signers for a group action
Parameters:
Options: Active, Closed
Example
System & Utility
Get Status
Get system status
Parameters:
No parameters required
Example
Get Current Quorums Info
Get information about current quorums
Parameters:
No parameters required
Example
Get Prefunded Specialized Balance
Get prefunded specialized balance
Parameters:
Example: AzaU7zqCT7X1kxh8yWxkT9PxAgNqWDu4Gz13emwcRyAT
Example
Get Total Credits in Platform
Get total credits in the platform
Parameters:
No parameters required
Example
Get Path Elements
Access any data in the Dash Platform state tree. This low-level query allows direct access to GroveDB storage by specifying a path through the tree structure and keys to retrieve at that path. Common paths include: Identities (32), Tokens (96), DataContractDocuments (64), Balances (16), Votes (80), and more.
Parameters:
Example
Common Path Values:
| Path Value | Description |
|---|---|
64 | Data Contract Documents |
32 | Identities |
24 | Unique Public Key Hashes to Identities |
8 | Non-Unique Public Key Hashes to Identities |
16 | Tokens |
48 | Pools |
40 | Prefunded Specialized Balances |
72 | Spent Asset Lock Transactions |
80 | Withdrawal Transactions |
88 | Group Actions |
96 | Balances |
104 | Misc |
112 | Votes |
120 | Versions |
Example Paths:
[32, identity_id]- Access identity data[96, identity_id]- Access identity balance[16, contract_id, token_id]- Access token info[64, contract_id, 1, document_type]- Access documents by type[88, contract_id, group_position]- Access group actions[112]- Access votes tree
Wait for State Transition Result
Internal query to wait for and retrieve the result of a previously submitted state transition
Parameters:
Example
This is an internal query used to wait for and retrieve the result of a previously submitted state transition. It requires a valid state transition hash from a prior operation.
State Transitions
Identity Transitions
Identity Create
Create a new identity with initial credits
Parameters:
Hex-encoded JSON asset lock proof
WIF format private key
JSON array of public keys
Example
Identity Top Up
Add credits to an existing identity
Parameters:
Base58 format identity ID
Hex-encoded JSON asset lock proof
WIF format private key
Example
Identity Update
Update identity keys (add or disable)
Parameters:
Example: [{"keyType":"ECDSA_HASH160","purpose":"AUTHENTICATION","data":"base64_key_data"}]
Example: 2,3,5
Example
Identity Credit Transfer
Transfer credits between identities
Parameters:
Example
Identity Credit Withdrawal
Withdraw credits from identity to Dash address
Parameters:
Example
Data Contract Transitions
Data Contract Create
Create a new data contract
Parameters:
Example: { "note": { "type": "object", "properties": { "message": { "type": "string", "maxLength": 100, "position": 0 } }, "required": ["message"], "additionalProperties": false } }
Example: {}
Example: {}
Example
Data Contract Update
Add document types, groups, or tokens to an existing data contract
Parameters:
Example: { "newType": { "type": "object", "properties": { "field": { "type": "string", "maxLength": 100, "position": 0 } }, "required": ["field"], "additionalProperties": false } }
Example: {}
Example: {}
Example
Document Transitions
Document Create
Create a new document
Parameters:
Example
Document Replace
Replace an existing document
Parameters:
Example
Document Delete
Delete an existing document
Parameters:
Example
Document Transfer
Transfer document ownership
Parameters:
Example
Document Purchase
Purchase a document
Parameters:
Example
Document Set Price
Set or update document price
Parameters:
Example
DPNS Register Name
Register a new DPNS username
Parameters:
Example: Enter username (e.g., alice)
Example
Token Transitions
Token Burn
Burn tokens
Parameters:
Example
Token Mint
Mint new tokens
Parameters:
Example
Token Claim
Claim tokens from a distribution
Parameters:
Options: Perpetual, Pre-programmed
Example
Token Set Price
Set or update the price for direct token purchases
Parameters:
Options: Single Price, Tiered Pricing
Example: Leave empty to remove pricing
Example
Token Direct Purchase
Purchase tokens directly at the configured price
Parameters:
Example
Token Config Update
Update token configuration settings
Parameters:
Options: Conventions, Max Supply, Perpetual Distribution, New Tokens Destination Identity, Minting Allow Choosing Destination, Manual Minting, Manual Burning, Conventions Control Group, Conventions Admin Group, Max Supply Control Group, Max Supply Admin Group
Example
Token Transfer
Transfer tokens between identities
Parameters:
Example
Token Freeze
Freeze tokens for a specific identity
Parameters:
Example
Token Unfreeze
Unfreeze tokens for a specific identity
Parameters:
Example
Token Destroy Frozen
Destroy frozen tokens
Parameters:
Example
Voting Transitions
DPNS Username
Cast a vote for a contested DPNS username
Parameters:
Example: Enter the contested username (e.g., 'myusername')
Options: Abstain, Lock (Give to no one), Vote for Identity
Example: Identity ID to vote for
Example
Contested Resource
Cast a vote for contested resources as a masternode
Parameters:
Example: Contract ID containing the contested resource
Options: Abstain, Lock (Give to no one), Vote for Identity
Example: Identity ID to vote for