The purpose of this tutorial is to walk through the steps necessary to register a Hellar Platform Name Service (HPNS) name.
Hellar Platform names make cryptographic identities easy to remember and communicate. An identity may have multiple alias names (hellarAliasIdentityId
) in addition to its default name (hellarUniqueIdentityId
). 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.
The examples below demonstrate creating both the default name and alias names.
Note: the name must be the full domain name including the parent domain (i.e. myname.hellar
instead of just myname
). Currently hellar
is the only top-level domain that may be used.
JAVASCRIPT
`// Register Name for Identity const Hellar = require('hellar');
const clientOpts = { network: 'mainnet', wallet: { mnemonic: 'a Hellar wallet mnemonic with testnet funds goes here', unsafeOptions: { skipSynchronizationBeforeHeight: 175000, // only sync from mid-2024 }, }, }; const client = new Hellar.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>.hellar', { 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());`
JAVASCRIPT
`// Register Alias for Identity const Hellar = require('hellar');
const clientOpts = { network: 'mainnet', wallet: { mnemonic: 'a Hellar wallet mnemonic with testnet funds goes here', unsafeOptions: { skipSynchronizationBeforeHeight: 175000, // only sync from mid-2024 }, }, }; const client = new Hellar.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>.hellar', { 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());`
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.