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

Register a Name for an Identity

Sign up for a name in the Dash Platform Name Service (DPNS)

The purpose of this tutorial is to walk through the steps necessary to register a Dash Platform Name Service (DPNS) name.

Overview

Dash Platform names make cryptographic identities easy to remember and communicate. As of Dash Platform v0.15, an identity may have multiple alias names (dashAliasIdentityId) in addition to its default name (dashUniqueIdentityId). Additional details regarding identities can be found in the Identity description.

Note: An identity must have a default name before any aliases can be created for the identity.

Prerequisites

Code

The examples below demonstrate creating both the default name and alias names.

📘

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.

🚧

The name must be the full domain name including the parent domain (i.e. myname.dash instead of just myname). Currently dash is the only top-level domain that may be used.

const Dash = require('dash');

const clientOpts = {
  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 registerName = async () => {
  const { platform } = client;

  const identity = await platform.identities.get('an identity ID goes here');
  const nameRegistration = await platform.names.register(
    '<identity name goes here>.dash',
    { dashUniqueIdentityId: identity.getId() },
    identity,
  );

  return nameRegistration;
};

registerName()
  .then((d) => console.log('Name registered:\n', d.toJSON()))
  .catch((e) => console.error('Something went wrong:\n', e))
  .finally(() => client.disconnect());
const Dash = require('dash');

const clientOpts = {
  wallet: {
    mnemonic: 'a Dash wallet mnemonic with evonet funds goes here',
  },
};
const client = new Dash.Client(clientOpts);

const registerAlias = async () => {
  const platform = client.platform;
  const identity = await platform.identities.get('an identity ID goes here');
  const aliasRegistration = await platform.names.register(
    '<identity alias goes here>.dash',
    { dashAliasIdentityId: identity.getId() },
    identity,
  );

  return aliasRegistration;
};

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

What's Happening

After initializing the Client, we fetch the Identity we'll be associating with a name. This is an asynchronous method so we use await to pause until the request is complete. Next, we call platform.names.register and pass in the name we want to register, the type of identity record to create, and the identity we just fetched. We wait for the result, and output it to the console.