Dash Platform

Dash Platform Developer Documentation

Welcome to the Dash Platform developer documentation. You'll find guides and documentation to help you start working with Dash Platform as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Send Funds

Overview

Once you have a wallet and some funds (tutorial), another common task is sending Dash to an address. (Sending Dash to a contact or a DPNS identity requires the Dashpay app, which has not been registered yet.)

Code

🚧

Wallet Operations

Currently, the JavaScript SDK does not cache wallet information, and therefore, it re-syncs the entire Core chain for some wallet operations (e.g. client.getWalletAccount()). This can result in wait times of 5+ minutes. An upcoming release will add a persistence feature to cache wallet information during initial sync so that subsequent access is much faster.

const Dash = require('dash');

const clientOpts = {
  network: 'testnet',
  wallet: {
    mnemonic: 'your wallet mnemonic goes here',
    unsafeOptions: {
      skipSynchronizationBeforeHeight: 415000, // only sync from start of 2021
    },
  },
};
const client = new Dash.Client(clientOpts);

const sendFunds = async () => {
  const account = await client.getWalletAccount();

  const transaction = account.createTransaction({
    recipient: 'yP8A3cbdxRtLRduy5mXDsBnJtMzHWs6ZXr', // Testnet2 faucet
    satoshis: 100000000, // 1 Dash
  });
  return account.broadcastTransaction(transaction);
};

sendFunds()
  .then((d) => console.log('Transaction broadcast!\nTransaction ID:', d))
  .catch((e) => console.error('Something went wrong:\n', e))
  .finally(() => client.disconnect());

// Handle wallet async errors
client.on('error', (error, context) => {
  console.error(`Client error: ${error.name}`);
  console.error(context);
});

What's Happening

After initializing the Client, we build a new transaction with account.createTransaction. It requires a recipient and an amount in satoshis (often called "duffs" in Dash). 100 million satoshis equals one Dash. We pass the transaction to account.broadcastTransaction and wait for it to return. Then we output the result, which is a transaction ID. After that we disconnect from the Client so node can exit.

Updated 3 months ago



Send Funds


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.