LoginSignup
2
1

More than 3 years have passed since last update.

Symbolでnemaspaceを作ってみる

Last updated at Posted at 2021-04-04

ネームスペースの作成

duration(ネームスペースのレンタル期間)は下記式で計算できる。

// 86400s = 24h
// blockGenerationTargetTimeInSeconds: デフォルト30s
duration≈日数∗86400/blockGenerationTargetTimeInSeconds
% symbol-cli transaction namespace
✔ Enter your wallet password: … ************
✔ Enter the namespace name: … ccsmurai
✔ Do you want to create a root namespace? … yes
✔ Enter the maximum fee (absolute amount): … 2000000
✔ Select the transaction announce mode: › normal
✔ Enter the duration in number of blocks: … 172800 //60日

┌────────────────────────────────────────────────────────────────────────────────────┐
│                               NAMESPACE_REGISTRATION                               │
├─────────────────┬──────────────────────────────────────────────────────────────────┤
│ Max fee:        │ 2,000,000                                                        │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network type:   │ TEST_NET                                                         │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Deadline:       │ 2021-04-04 13:02:24.456                                          │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Namespace name: │ ccsmurai                                                         │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Type:           │ Root namespace                                                   │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Duration:       │ 172800 blocks                                                    │
├─────────────────┴──────────────────────────────────────────────────────────────────┤
│                                 Signature details                                  │
├─────────────────┬──────────────────────────────────────────────────────────────────┤
│ Payload:        │ 9A000000000000003078D131AD1F8C8FBF8932023C33A9C69D6761145D47AA13 │
│                 │ A8E2785A4EB3BB1DF016EFE546E783E39B6F9A680FD4EF4E8DE891796F896FD0 │
│                 │ 1C14F831B57B880CC179986233ADC2507DFCF301C005548DF2F8819EF7497681 │
│                 │ D7CBB1109B22E5350000000001984E4180841E0000000000483649430A000000 │
│                 │ 00A30200000000004B7C7E01EAEF1AE500086363736D75726169             │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Hash:           │ 04A0C7F97F9A962E1B7C690C770F7B646EE438ADA18F3821EF208C0717C25924 │
├─────────────────┼──────────────────────────────────────────────────────────────────┤
│ Signer:         │ C179986233ADC2507DFCF301C005548DF2F8819EF7497681D7CBB1109B22E535 │
└─────────────────┴──────────────────────────────────────────────────────────────────┘

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

% symbol-cli transaction namespace --subnamespace --parent-name ccsmurai --name stock

ここまでで作成したネームスペース、サブネームスペースを確認

% symbol-cli namespace owned

Namespace Information
┌───────────────────┬───────────────────────────────────────────────┐
│ Property          │ Value                                         │
├───────────────────┼───────────────────────────────────────────────┤
│ Id                │ E51AEFEA017E7C4B                              │
├───────────────────┼───────────────────────────────────────────────┤
│ Registration Type │ Root Namespace                                │
├───────────────────┼───────────────────────────────────────────────┤
│ Owner             │ TAK7KS-KD4EVH-XCWF45-DAKU6X-AZGH22-CRFFZ6-3JY │
├───────────────────┼───────────────────────────────────────────────┤
│ Start Height      │ 245854                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ End Height        │ 421534                                        │
└───────────────────┴───────────────────────────────────────────────┘

Namespace Information
┌───────────────────┬───────────────────────────────────────────────┐
│ Property          │ Value                                         │
├───────────────────┼───────────────────────────────────────────────┤
│ Id                │ 8D5DE16E917C3BC5                              │
├───────────────────┼───────────────────────────────────────────────┤
│ Registration Type │ Sub Namespace                                 │
├───────────────────┼───────────────────────────────────────────────┤
│ Owner             │ TAK7KS-KD4EVH-XCWF45-DAKU6X-AZGH22-CRFFZ6-3JY │
├───────────────────┼───────────────────────────────────────────────┤
│ Start Height      │ 245854                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ End Height        │ 421534                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ Parent Id         │ E51AEFEA017E7C4B                              │
└───────────────────┴───────────────────────────────────────────────┘

ネームスペースをモザイクへリンクする

あらかじめ用意しておいたmosaic:58DF8E44BCBC1CD3とネームスペースをリンクする

% symbol-cli transaction mosaicalias 
✔ Enter your wallet password: … ************
✔ Enter the namespace name: … ccsmurai
✔ Enter the mosaic id in hexadecimal format: … 58DF8E44BCBC1CD3
✔ Select an action: › Link
✔ Enter the maximum fee (absolute amount): … 2000000
✔ Select the transaction announce mode: › normal

リンクされていることを確認

% symbol-cli namespace info 
✔ Enter the namespace id in hexadecimal: … E51AEFEA017E7C4B

Namespace Information
┌───────────────────┬───────────────────────────────────────────────┐
│ Property          │ Value                                         │
├───────────────────┼───────────────────────────────────────────────┤
│ Id                │ E51AEFEA017E7C4B                              │
├───────────────────┼───────────────────────────────────────────────┤
│ Registration Type │ Root Namespace                                │
├───────────────────┼───────────────────────────────────────────────┤
│ Owner             │ TAK7KS-KD4EVH-XCWF45-DAKU6X-AZGH22-CRFFZ6-3JY │
├───────────────────┼───────────────────────────────────────────────┤
│ Start Height      │ 245854                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ End Height        │ 421534                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ Alias Type        │ MosaicId                                      │
├───────────────────┼───────────────────────────────────────────────┤
│ Alias MosaicId    │ 58DF8E44BCBC1CD3                              │
└───────────────────┴───────────────────────────────────────────────┘

モザイクとリンクしたかったネームスペースはサブネットの方だったので、unlinkしてからリンクしなおす。

# モザイクとサブネームスペースをlink
。
# 一つのモザイクがネームスペースと、サブネームスペースの両方にlinkすることは可能なのですね。TODO:仕様チェック
# サブネームスペースの書き方は、<ネームスペース>.<サブネームスペース>
% symbol-cli transaction mosaicalias 
✔ Enter your wallet password: … ************
✔ Enter the namespace name: … ccsmurai.stock
✔ Enter the mosaic id in hexadecimal format: … 58DF8E44BCBC1CD3
✔ Select an action: › Link
✔ Enter the maximum fee (absolute amount): … 2000000
✔ Select the transaction announce mode: › normal
# ネームスペースとモザイクをunlinkする
% symbol-cli transaction mosaicalias 
✔ Enter your wallet password: … ************
✔ Enter the namespace name: … ccsmurai
✔ Enter the mosaic id in hexadecimal format: … 58DF8E44BCBC1CD3
✔ Select an action: › Unlink // Unlinkを指定
✔ Enter the maximum fee (absolute amount): … 2000000
✔ Select the transaction announce mode: › normal

# ネームスペースはunlinkされた
% symbol-cli namespace info 
✔ Enter the namespace id in hexadecimal: … E51AEFEA017E7C4B

Namespace Information
┌───────────────────┬───────────────────────────────────────────────┐
│ Property          │ Value                                         │
├───────────────────┼───────────────────────────────────────────────┤
│ Id                │ E51AEFEA017E7C4B                              │
├───────────────────┼───────────────────────────────────────────────┤
│ Registration Type │ Root Namespace                                │
├───────────────────┼───────────────────────────────────────────────┤
│ Owner             │ TAK7KS-KD4EVH-XCWF45-DAKU6X-AZGH22-CRFFZ6-3JY │
├───────────────────┼───────────────────────────────────────────────┤
│ Start Height      │ 245854                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ End Height        │ 421534                                        │
└───────────────────┴───────────────────────────────────────────────┘

# サブネームスペースはmosaicとリンクされている
% symbol-cli namespace info 
✔ Enter the namespace id in hexadecimal: … 8D5DE16E917C3BC5

Namespace Information
┌───────────────────┬───────────────────────────────────────────────┐
│ Property          │ Value                                         │
├───────────────────┼───────────────────────────────────────────────┤
│ Id                │ 8D5DE16E917C3BC5                              │
├───────────────────┼───────────────────────────────────────────────┤
│ Registration Type │ Sub Namespace                                 │
├───────────────────┼───────────────────────────────────────────────┤
│ Owner             │ TAK7KS-KD4EVH-XCWF45-DAKU6X-AZGH22-CRFFZ6-3JY │
├───────────────────┼───────────────────────────────────────────────┤
│ Start Height      │ 245854                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ End Height        │ 421534                                        │
├───────────────────┼───────────────────────────────────────────────┤
│ Parent Id         │ E51AEFEA017E7C4B                              │
├───────────────────┼───────────────────────────────────────────────┤
│ Alias Type        │ MosaicId                                      │
├───────────────────┼───────────────────────────────────────────────┤
│ Alias MosaicId    │ 58DF8E44BCBC1CD3                              │
└───────────────────┴───────────────────────────────────────────────┘

aliasを使ってモザイクを転送してみる

% symbol-cli transaction transfer --recipient-address TDS3ZA-G6BI26-UZAOXS-GAL7TL-FZLYOP-S3SODM-SFI --mosaics @ccsmurai.stock::10  --max-fee 2000000 --message "10stack" --sync

転送できていることを確認。

% symbol-cli account info --address TDS3ZA-G6BI26-UZAOXS-GAL7TL-FZLYOP-S3SODM-SFI
...
Balance Information
┌──────────────────┬─────────────────┬─────────────────┬───────────────────┐
│ Mosaic Id        │ Relative Amount │ Absolute Amount │ Expiration Height │
├──────────────────┼─────────────────┼─────────────────┼───────────────────┤
│ 58DF8E44BCBC1CD3 │ 10              │ 10              │ Never             │
└──────────────────┴─────────────────┴─────────────────┴───────────────────┘ 

関連・参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1