Dash is a cryptocurrency launched in 2014 that aims to be a convenient, fast, and private digital cash platform that is suitable for everyday transactions.
Dash is a digital cryptocurrency that was launched in 2014. Originally called XCoin (XCO), it was renamed Darkcoin and then finally rebranded as Dash in 2015. “Dash” is a portmanteau of “Digital Cash” and was created as a fork of Bitcoin. Despite its origins, today Dash differs significantly from Bitcoin by aiming to be a convenient, fast, and private digital cash platform that is suitable for everyday transactions. This goal is reflected in its design features which include:
PrivateSend: This feature ensures user privacy by mixing transactions together, making them untraceable to individual users.
InstantSend: Dash’s InstantSend feature enables near-instant transaction confirmations that are faster than Bitcoin’s.
Masternodes: Dash’s network includes masternodes (or full nodes) which power its unique features like InstantSend and PrivateSend, as well as its governance system.
Decentralized Autonomous Organization: Dash operates as a DAO, meaning it is a transparent, member-controlled organization free from central government influence.
Block Reward Allocation: Dash’s block reward is split between miners (45%), masternodes (45%), and a development fund (10%), ensuring ongoing platform maintenance and development.
In 2019, an MVP of the Dash Platform (originally codenamed “Evonet”) was launched. The Dash Platform is a technology stack for building decentralized applications (dApps) on the Dash network. It represents a shift away from the original, transaction-focused blockchain systems inspired by Bitcoin by aiming to make Dash more like newer, application-focused blockchains such as Ethereum and Solana.
Key features of the platform include:
Dash Drive: A decentralized API that lets users store and interact with data on the Dash network, similar to a cloud database service.
Decentralized API (DAPI): Allows developers secure, decentralized access to full node capabilities without needing to host one.
Platform Chain: A separate chain for storing platform data, secured by the masternodes of the main Dash network.
Dash Libraries: A collection of integrated open source libraries for developing on the Dash Platform.
Here’s an architectural overview of the Dash Platform to get a better sense of how the different parts of the platform relate to one another:
Setup and Configure Node Project
Requirement: Node v20 or higher
Add the following to .gitignore:
We’ll create each script file individually throughout the tutorial but for the sake of simplifying your life while following along with this tutorial, I’d recommend adding all of the Node scripts that will be implemented by the end of the tutorial.
Open package.json and include the following scripts:
Initialize Dash Client
Create a scripts directory for our Node scripts and an api directory with a file called client.js for initializing Dash.Client. The network will be set to testnet via the NETWORK environment variable in .env.
Import Dash from dash, pass the project’s network and wallet configuration through Dash’s Client constructor, and export client.
Because we haven’t created a wallet yet, mnemonic is set to null to indicate we want a new wallet to be generated.
To get a new address for an existing wallet replace null with an existing wallet mnemonic.
offlineMode is set to true, indicating we don’t want to sync the chain.
This can only be used when the mnemonic is set to null.
Create Wallet and Identity
Create a file called createWallet.js.
We’ll use three functions to create a wallet:
getWalletAccount() to get our wallet.
exportWallet() to export the 12 word mnemonic phrase.
getUnusedAddress() to create a new address.
Run the createWallet script.
The output will include our two environment variables:
Copy these and place them in your .env. We’ll do the same throughout the rest of this tutorial.
Add Funds to Wallet with Testnet Faucet
Send test funds to the “unused address” from the console output using Dash’s testnet faucet. Wait for the funds to be confirmed before trying to use them, it may take a few minutes. You can check the status of confirmations with the Dash block explorer.
Search for your wallet address (yfvkghuK1fbDc7GBeadfMa47d9WaBpLxij in my case) to see your balance and list of transactions:
Click on the transaction link (9ca05a57d2f8e55068a5c8be4453d3a84aa852304d1aa3d32d92b9b5afe32261 in my case) to view information on the transaction itself.
You can also click on the plus symbol (+) next to the transaction link for more information related to the transaction confirmation.
Register and Retrieve Identity
Modify the client again and include your wallet’s MNEMONIC seed phrase saved in .env.
Create a file called createIdentity.js.
To create an identity, we’ll run the identities.register() function.
Run the createIdentity script.
Output:
Earlier, we saw how to view our transactions on the Dash block explorer. For operations performed on Dash Platform, there is a separate explorer at platform-explorer.com.
Open the Identities tab to see your ID on the list.
Alternatively, createIdentity appends the ID to the URL https://platform-explorer.com/identity/ and outputs the link to your terminal for convenience.
Create a file called retrieveIdentities.js.
getIdentityIds() with return your identity ID’s which can be passed to identities.get().
Run the retrieveIdentities script:
Output:
When an Identity is created, a special transaction transforms Dash into credits which are used to interact with Dash Platform. 1 DASH is equal to 100,000,000 Duffs (Dash’s version of the Satoshi) and 100 million Duffs is equal to 100 billion credits. Since interacting with Dash Platform applications decreases your credit balance, at a certain point you’ll need to topup the balance by converting some Dash to credits.
Create a file called topUpIdentities.js.
getIdentityIds() will be used again and the ID’s will be passed to identities.topUp().
A Data Contract on Dash Platform serves as a blueprint for the structure of data that an application intends to store on the decentralized network. It defines the schema of documents (data records) with JSON Schema.
Contracts enable the platform to validate data against these schemas to ensure consistency and integrity.
They are crucial for dApps and provide a structured and predictable way to interact with the Dash blockchain.
Data Contracts facilitate data storage, retrieval, and manipulation in a trustless environment.
You can create Data Contracts through an online user interface at dashpay.io.
Register, Retrieve, and Update Contract
Create a file called registerContract.js.
contracts.create() will take your identity and a spec for the contract. In this case the contract will be a simple string message.
Use your identity ID and contract ID along with setDocumentSchema() and contracts.update().
Run the updateContract script.
Contract updated:
Add an apps object to the client options and pass the contract ID to enable <contract name>.<contract document> syntax while accessing contract documents (for example, tutorialContract.note).
Submit and Retrieve Documents
Create a file called submitNoteDocument.js.
Add the following to scripts/submitNoteDocument.js.
Run the submitNoteDocument script.
Output:
Create a file called getDocuments.js.
Add the following to scripts/getDocuments.js.
Run the getDocuments script:
Output:
Update and Delete Documents
Create a file called updateNoteDocument.js.
Add the following to scripts/updateNoteDocument.js.
Run the updateNoteDocument script:
Output:
Document updated:
Now that we can create, read, and update our notes, all we have left to do is delete our notes. Create a file called deleteNoteDocument.js.
Add the following to scripts/deleteNoteDocument.js.
Run the deleteNoteDocument script:
Document deleted:
Setup Backend Server with Express
We’ve now learned how to run individual scripts to perform all the main functionality on the Dash Platform. Like any JavaScript library, we can extend this functionality with a backend and frontend. Let’s create an Express server that will return information on a given identity name.
Create a /name endpoint that will take an identity name:
Start the server with the following command:
Open localhost:3001/name/YOUR-NAME-HERE or send a GET request with curl.
Create Next App
Now we’ll add a frontend and use Next.js to build a React based UI.
Select Yes for using the src directory and also for using the App Router.
Open page.js in next/src/app and include the following code:
Start your server with the following command:
Setup React Project Structure
Now let’s include the logic to fetch our name. First, create a new .env.local file in your Next.js project and add NEXT_PUBLIC_LABEL="" with your label.
Add Fetch Button to React App
Now lets add a button that when clicked will fetch our name information.
In future blog posts we’ll expand out our frontend to include more of the functionality included in our Node scripts. We’ll also build out front-ends with other popular frameworks.