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
- node.js (v12+)
- Basic familiarity with JavaScript asychronous functions using async/await
- The Dash JavaScript SDK is initialized (covered in Connecting to EvoNet)
- A wallet mnemonic
- A Dash Platform Identity: Tutorial: Register an Identity
Code
const Dash = require('dash');
const client = new Dash.Client({
network: 'evonet',
wallet: {
mnemonic: 'a Dash wallet mnemonic with evonet 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.
Updated about 4 years ago