Hey! These docs are for version 0.17.0, which is no longer officially supported. Click here for the latest version, 0.21.0!

Create and Fund a Wallet

Overview

In order to make changes on Dash Platform, you need a wallet with a balance. This tutorial explains how to generate a new wallet, retrieve an address from it, and transfer test funds to the address from a faucet.

Prerequisites

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: null, // this indicates that we want a new wallet to be generated
                    // if you want to get a new address for an existing wallet
                    // replace 'null' with an existing wallet mnemonic
  },
};

const client = new Dash.Client(clientOpts);

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

  const mnemonic = client.wallet.exportWallet();
  const address = account.getUnusedAddress();
  console.log('Mnemonic:', mnemonic);
  console.log('Unused address:', address.address);
};

createWallet()
  .catch((e) => console.error('Something went wrong:\n', e))
  .finally(() => client.disconnect());
Mnemonic: thrive wolf habit timber birth service crystal patient tiny depart tower focus
Unused address: yXF7LsyajRvJGX96vPHBmo9Dwy9zEvzkbh

🚧

Please save your mnemonic for the next step and for re-use in subsequent tutorials throughout the documentation.

What's Happening

Once we connect, we output the newly generated mnemonic from client.wallet.exportWallet() and an unused address from the wallet from account.getUnusedAddress().

Next Step

Using the faucet at http://testnet-452625393.us-west-2.elb.amazonaws.com/, send test funds to the "unused address" from the console output. You will need to wait until the funds are confirmed to use them. There is a block explorer running at https://testnet-insight.dashevo.org/insight/ which can be used to check confirmations.


Did this page help you?