Register a name for an identity#

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 by enabling them to link to one or more names. Additional details regarding identities can be found in the Identity description.

Prerequisites#

Code#

Tip

The name must be the full domain name including the parent domain (i.e. myname.dash rather than myname). Currently, only the dash top-level domain may be used.

const setupDashClient = require('../setupDashClient');

const client = setupDashClient();

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',
    { identity: 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());

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.

Note

Since the SDK does not cache wallet information, lengthy re-syncs (5+ minutes) may be required for some Core chain wallet operations. See Wallet Operations for options.