Guides
Dash CoreDash PlatformDash.orgDash User DocsLog In
Guides
These docs are for v0.17.0. Click to read the latest docs for v0.25-redirect.

Retrieve an Account's Identities

Get the list of Dash Platform Identities associated with an account

Overview

In this tutorial we will retrieve the list of identities associated with a specified mnemonic-based account. Since multiple identities may be created using the same mnemonic, it is helpful to have a way to quickly retrieve all these identities (e.g. if importing the mnemonic into a new device).

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 client = new Dash.Client({
  network: 'testnet',
  wallet: {
    mnemonic: 'a Dash wallet mnemonic with testnet funds goes here',
  },
});

const retrieveIdentityIds = async () => {
  const account = await client.getWalletAccount();
  return account.getIdentityIds();
};

retrieveIdentityIds()
  .then((d) => console.log('Mnemonic identities:\n', d))
  .catch((e) => console.error('Something went wrong:\n', e))
  .finally(() => client.disconnect());

Example Response

[
  '8DpCxc6CY1vHQzQVv8EezN4fpKis5K2YuxGYRSiccsC8',
  '4SUjmwadgF8LLxnjXchhkNtw7tfgacg82CuZegWktW61'
]

What's Happening

After we intialize the Client and getting the account, we call account.getIdentityIds to retrieve a list of all identities created with the wallet mnemonic. The list of identities is output to the console.