Extending a namespace registration period

This guide shows you how to extend the rental period of a namespace.

Background

Namespaces are registered for a certain amount of blocks. The creator can extend the registration period by sending a NamespaceRegistrationTransaction with the desired number of additional blocks.

The guide will use the namespace foo, but you should follow along with another namespace you have registered.

Prerequisites

  • Complete registering a namespace guide.
  • Have an account with a namespace.
  • Have an account with enough symbol.xym to pay for the transaction and renewal fees.

Method #01: Using the Desktop Wallet

  1. Click on the “Namespaces” on the left-side menu.
  2. Click on the “Edit” button (pen symbol) for the namespace you desire to extend the duration of. Then click on “Extend duration”.
../../_images/extend-namespace-1.gif
  1. Enter the amount of blocks to extend the duration of the namespace. Select the amount of fees you are willing to spend. Click “Send”.
  2. Review the information, enter your wallet password, and click “Confirm”.
../../_images/extend-namespace-2.gif

Method #02: Using the SDK

  1. Get your namespace information, and inspect the value of the property endHeight.
symbol-cli namespace info --name foo

Namespace: foo
--------------

hexadecimal:    82a9d1ac587ec054
uint:           [ 1484701780, 2192167340 ]
type:           Root namespace
owner:          TBULEA...IPS4
startHeight:    52000
endHeight:      53000

The information shows that the namespace foo will become inactive at height 5300. The next step is to figure out the current height of the chain, and calculate the number of blocks remaining before your namespace becomes inactive.

  1. Check the current blockchain height.
symbol-cli blockchain height

52500

As you can see, the namespace is going to expire in 500 blocks (53000-52500). To avoid losing all the subnamespaces and aliases linked to foo, we are going to extend the namespace duration.

  1. Extend the namespace duration for 172800 more 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(),
    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 = 'http://api-01.us-east-1.096x.symboldev.network:3000';
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 = symbol_sdk_1.UInt64.fromUint(172800);
// replace with network type
const networkType = symbol_sdk_1.NetworkType.TEST_NET;
const namespaceRegistrationTransaction = symbol_sdk_1.NamespaceRegistrationTransaction.createRootNamespace(symbol_sdk_1.Deadline.create(), namespaceName, duration, networkType, symbol_sdk_1.UInt64.fromUint(2000000));
// replace with private key
const privateKey = '1111111111111111111111111111111111111111111111111111111111111111';
const account = symbol_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 = 'http://api-01.us-east-1.096x.symboldev.network:3000';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
transactionHttp
    .announce(signedTransaction)
    .subscribe((x) => console.log(x), (err) => console.error(err));

Note

Use the following formula to convert approximately days to blocks duration numberOfDays * 86400 / blockGenerationTargetTime.

Once the RegisterNamespaceTransaction gets confirmed, double-check that the namespace duration has been extended.

  1. Validate that endHeight has increased by 172800 block units.
symbol-cli namespace info --namespace-name foo

Namespace: foo
--------------

hexadecimal:    82a9d1ac587ec054
uint:           [ 1484701780, 2192167340 ]
type:           Root namespace
owner:          TCHBDE...32I
startHeight:    52000
endHeight:      225800

Method #03: Using the CLI

To extend the namespace duration, open a terminal window and run the following command. Replace foo with the namespace name and 172800 with the number of blocks to extend.

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