Register an Identity

Establish an Identity on Dash Platform

The purpose of this tutorial is to walk through the steps necessary to register an identity.

Overview

Identities serve as the basis for interactions with Dash Platform. They consist primarily of a public key used to register a unique entity on the network. Additional details regarding identities can be found in the Identity description.

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. For now, the skipSynchronizationBeforeHeight option can be used to only sync the wallet starting at a certain block height.

❗️

Dash Platform v0.18 Breaking Change

The derivation path used for identities has been updated to align with DIP13 and provide compatibility with the mobile DashPay wallets. Consequently, identities registered with previous versions of the SDK will be not be retrievable.

Also note the change from account.getIdentityIds() to account.identities.getIdentityIds() for retrieving identities (PR).

const Dash = require('dash');

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

const createIdentity = async () => {
  return client.platform.identities.register();
};

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

The Identity will be output to the console. The Identity will need to have one confirmation before it is accessible via client.platform.identity.get.

👍

Make a note of the returned identity id as it will be used used in subsequent tutorials throughout the documentation.

What's Happening

After connecting to the Client, we call platform.identities.register. This will generate a keypair and submit an Identity Create State Transaction. After the Identity is registered, we output it to the console.


Did this page help you?