This guide shows you how to extend the rental period of a namespace.
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.
symbol.xym to pay for the transaction and renewal fees.
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.
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.
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.
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
Did you find what you were looking for? Give us your feedback.