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.
Additional details regarding identities can be found in the Identity description.
For this tutorial you will need:
- A wallet mnemonic with some funds in it: Tutorial: Create and Fund a Wallet
- A dash platform identity: Tutorial: Register an Identity
- A name you want to register: Name restrictions
As of v3.14.0 of the Dash JavaScript SDK, the name must be the full domain name including the parent domain (i.e.
myname.dash
instead of justmyname
). Currentlydash
is the only top-level domain that may be used.
Code
const Dash = require('dash');
const clientOpts = {
network: 'evonet',
wallet: {
mnemonic: 'a Dash wallet mnemonic with evonet funds goes here',
}
};
const client = new Dash.Client(clientOpts);
const registerName = async function () {
try {
const platform = client.platform;
const identity = await platform.identities.get('an identity ID goes here');
const nameRegistration = await platform.names.register('a name goes here', identity);
console.log({nameRegistration});
} catch (e) {
console.error('Something went wrong:', e);
} finally {
client.disconnect();
}
}
registerName();
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, and the identity we just fetched. We wait for the result, and output it to the console.
Updated over 3 years ago