サブネームスペースの作成

ルート ネームスペース を取得すると 3 つまでのサブネームスペースを作って、アセットの整理をすることができます。

前提条件

方法 #01: デスクトップウォレットを使用する

  1. 左側のメニューの 「ネームスペース」 をクリックします。」サブネームスペースの作成」 タブへ遷移します。
  1. サブネームスペースの情報を入力します。 「送信」 をクリックします。ポップアップの情報を確認し、ウォレットのパスワードを入力します。 「確認」 をクリックします。
  1. Owned namespaces」 タブに戻って、サブネームスペースが作成されたことを確認できます。

サブネームスペースが作成されると、 モザイク または アドレス がサブネームスペースとリンクします。

方法 #02: SDK を使用する

次のコードスニペットは、ネームスペース foo の下に bar というサブネームスペースを作成します。

 // replace with root namespace name
const rootNamespaceName = 'foo';
// replace with root subnamespace name
const subnamespaceName = 'bar';
// replace with network type
const networkType = NetworkType.TEST_NET;
const namespaceRegistrationTransaction = NamespaceRegistrationTransaction.createSubNamespace(
  Deadline.create(epochAdjustment),
  subnamespaceName,
  rootNamespaceName,
  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.testnet.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 root namespace name
const rootNamespaceName = 'foo';
// replace with root subnamespace name
const subnamespaceName = 'bar';
// replace with network type
const networkType = symbol_sdk_1.NetworkType.TEST_NET;
const namespaceRegistrationTransaction = symbol_sdk_1.NamespaceRegistrationTransaction.createSubNamespace(
  symbol_sdk_1.Deadline.create(epochAdjustment),
  subnamespaceName,
  rootNamespaceName,
  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.testnet.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),
);

方法 #03: CLI を使用する

サブネームスペースを作成するには、ターミナルウィンドウを開き、次のコマンドを実行します。 foo をルートネームスペース名に置き換え、 bar を作成する新しいサブネームスペースに置き換えます。

 symbol-cli transaction namespace --subnamespace --parent-name foo --name bar