Registering a namespace

Create a unique name to identify your assets.

Prerequisites

Method #01: Using the Desktop Wallet

  1. Click on “Namespace” on the left-side menu.

resources/images/screenshots/desktop-register-namespace-1.gif
  1. Click on the “Create new namespaces” tab.

resources/images/screenshots/desktop-register-namespace-2.gif

3. Enter the information for your new namespace. Click “Send”. Verify the information on the popup and enter your wallet password. Click “Confirm”.

Note

The name must be unique in the network, and may have a maximum length of 64 characters, and the allowed characters are a, b, c, …, z, 0, 1, 2, …, 9, _ , -.

resources/images/screenshots/desktop-register-namespace-3.gif

4. You can check that the namespace has been created by going back to the “Owned namespaces” tab. If you don’t see your namespace, try clicking on the update icon.

resources/images/screenshots/desktop-register-namespace-4.gif

Note

To keep the ownership of your namespace, you will have to extend its duration before it expires.

When the transaction is confirmed, you can register a subnamespace following the next guide.

Method #02: Using the SDK

  1. Choose a unique name for your namespace. One common option is to use your company’s or own name.

  2. Check if the namespace name is available. For example, you can use the Command-line Interface to check if the namespace has been registered.

bitxor-cli namespace info --namespace-name foo
  1. Is the namespace available? Try to register it before someone else does it! Open a new file and announce a NamespaceRegistrationTransaction with the chosen name and renting duration expressed in blocks.

// replace with namespace name
const namespaceName = 'foo';
// replace with duration (in blocks)
const duration = UInt64.fromUint(172800);
// replace with network type
const networkType = NetworkType.TEST_NET;

const namespaceRegistrationTransaction = NamespaceRegistrationTransaction.createRootNamespace(
  Deadline.create(epochAdjustment),
  namespaceName,
  duration,
  networkType,
  UInt64.fromUint(2000000),
);

// replace with private key
const privateKey =
  '1111111111111111111111111111111111111111111111111111111111111111';
const account = Account.createFromPrivateKey(privateKey, networkType);
// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash =
  '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = account.sign(
  namespaceRegistrationTransaction,
  networkGenerationHash,
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();

transactionHttp.announce(signedTransaction).subscribe(
  (x) => console.log(x),
  (err) => console.error(err),
);
// replace with namespace name
const namespaceName = 'foo';
// replace with duration (in blocks)
const duration = bitxor_sdk_1.UInt64.fromUint(172800);
// replace with network type
const networkType = bitxor_sdk_1.NetworkType.TEST_NET;
const namespaceRegistrationTransaction = bitxor_sdk_1.NamespaceRegistrationTransaction.createRootNamespace(
  bitxor_sdk_1.Deadline.create(epochAdjustment),
  namespaceName,
  duration,
  networkType,
  bitxor_sdk_1.UInt64.fromUint(2000000),
);
// replace with private key
const privateKey =
  '1111111111111111111111111111111111111111111111111111111111111111';
const account = bitxor_sdk_1.Account.createFromPrivateKey(
  privateKey,
  networkType,
);
// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash =
  '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = account.sign(
  namespaceRegistrationTransaction,
  networkGenerationHash,
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new bitxor_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
transactionHttp.announce(signedTransaction).subscribe(
  (x) => console.log(x),
  (err) => console.error(err),
);

Note

To keep the ownership of your namespace, you will have to extend its duration before it expires.

Method #03: Using the CLI

To create a new namespace, open a terminal window and run the following command. Replace foo with the chosen namespace name and 172800 with the namespace duration expressed in blocks.

bitxor-cli transaction namespace --name foo --rootnamespace --duration 172800