LoginSignup
3
1

More than 3 years have passed since last update.

symbol-cliを触ってみたその2

Last updated at Posted at 2020-10-23

おはようございます。

昨日はよく眠れましたか?

そうですか、それはよかった。

その1がまだの人はこっち
https://qiita.com/kazumasamatsumo/private/07bc4f02925b96820237

Account

symbol-cli

と叩くと

スクリーンショット 2020-10-22 23.09.34.png

こんな感じでサブコマンドのリストがでます。

まずはこのaccountからみていきます。

accountのコマンドを叩きます

symbol-cli account

スクリーンショット 2020-10-22 23.10.59.png

はい

generateinfo

の2つがあります。

generateは新しくアカウントを作るとき。

infoは作ったアカウントの情報がみたい時に使います。

account generate

symbol-cli account generate --help
(base) ~% symbol-cli account generate --help

  Generate new accounts

  USAGE

    symbol-cli account generate [...options]

  OPTIONS

    --profile <profile>                    - (Optional) Select between your profiles, by providing a profile name.                                     
    --hd                                   - (Optional) Create an HD wallet.                                                                           
    -u, --url <url>                        - (Optional) When saving profile, provide a Symbol Node URL. Example: http://localhost:3000                 
    -n, --network <network>                - (Optional) Network Type. (MAIN_NET, TEST_NET, MIJIN, MIJIN_TEST)                                          
    -p, --password <password>              - (Optional) When saving profile, provide the password.                                                     
    -d, --default                          - (Optional) Set the profile as default.                                                                    
    -g, --generation-hash <generationHash> - (Optional) Generation hash of the network. Required to create the profile offline.                        
    -i, --namespace-id <namespaceId>       - (Optional) Namespace Name of the network mosaic. (eg.: symbol.xym) Required to create the profile offline.
    -v, --divisibility <divisibility>      - (Optional) Divisibility of the network mosaic. (eg.: 6) Required to create the profile offline.           
    -s, --save                             - (Optional) Saves the profile.                                                                             

(base) ~% 

スクリーンショットとるのしんどくなった。

オプションがいーーーーーーっぱいあります。

ですが

symbol-cli account generate

でいいです。

例えば

--hd

とかハードウェアウォレットなんて普段使わないし。

てかハードウェアウォレットって何?ってなるやん。

-g

とかジェネレーションハッシュ違うものにすると大変なことになったり。

とにかく面倒なことになるので(玄人仕様)

まずは僕と契約して一緒に作って行こうよ!!

symbol-cli account generate
(base) ~% symbol-cli account generate
? Select the network type: › - Use arrow-keys. Return to submit.
❯   MAIN_NET
    TEST_NET
    MIJIN
    MIJIN_TEST

ネットワークタイプどれ?

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
? Do you want to save the account? › (Y/n)

アカウントセーブしちゃっていい?

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
? Select an import type: › - Use arrow-keys. Return to submit.
❯   PrivateKey
    Mnemonic

アカウントのインポートする方法って何?

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
✔ Select an import type: › PrivateKey
? Enter the Symbol node URL. (Example: http://localhost:3000): › 

ノードのURL書くよろし。

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
✔ Select an import type: › PrivateKey
✔ Enter the Symbol node URL. (Example: http://localhost:3000): … http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000
? Enter a profile name: › 

プロファイルの名前何にする?

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
✔ Select an import type: › PrivateKey
✔ Enter the Symbol node URL. (Example: http://localhost:3000): … http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000
✔ Enter a profile name: … kazumasa
? Enter your wallet password: › 

パスワードは?

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
✔ Select an import type: › PrivateKey
✔ Enter the Symbol node URL. (Example: http://localhost:3000): … http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000
✔ Enter a profile name: … kazumasa
✔ Enter your wallet password: … *************
? Do you want to set the account as the default profile? › (Y/n)

デフォルトのプロファイルにする?

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
✔ Select an import type: › PrivateKey
✔ Enter the Symbol node URL. (Example: http://localhost:3000): … http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000
✔ Enter a profile name: … kazumasa
✔ Enter your wallet password: … *************
✔ Do you want to set the account as the default profile? … no

Account
┌───────────────┬──────────────────────────────────────────────────────────────────────┐
│ Property      │ Value                                                                │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Address       │ TDPHQF-2UXIBN-GJ2XCU-57PLG5-2COHZ3-EG7OBU-S2Y                        │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Public Key    │ DB40F9809BE0E4C5326D0796960D9D0EEB2815AB13424FD5896D48545F7BACC3     │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Private Key   │ 1A95BD65F0C4FC23B821FF4EAB29DDAD1151D37D1767F1908E2E81B4718B0067     │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Password      │ *************                                                        │
└───────────────┴──────────────────────────────────────────────────────────────────────┘

SUCCESS Stored kazumasa profile
(base) ~% 

でけた。

パスワード晒すほど馬鹿ではないのですが、cliで作成するとパスワードでます。

ここから通貨もらうといいよ。

とまぁこんな感じでアカウントが作れます。

symbol-cli profile create

と一緒かな?

ニーモニックで作ってみる

(base) ~% symbol-cli account generate
✔ Select the network type: › TEST_NET
✔ Do you want to save the account? … yes
✔ Select an import type: › Mnemonic
✔ Enter the Symbol node URL. (Example: http://localhost:3000): … http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000
✔ Enter a profile name: … muemonic
✔ Enter your wallet password: … *************
✔ Do you want to set the account as the default profile? … no

Account
┌───────────────┬──────────────────────────────────────────────────────────────────────┐
│ Property      │ Value                                                                │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Address       │ TDHHPD-2SLKLH-SFWYVQ-CAF65H-IR4GTI-6GW6AW-UGQ                        │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Public Key    │ 887BD2FA027C4C76903BD626846E4A079EE73AE411B09AD219841142B7C1F930     │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Private Key   │ 0CDCE858F01FD6C6B6BEE0B5B3A4A70F0975B4AE77DC10BDC91B97E5D56F2FCC     │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Password      │ *************                                                        │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Mnemonic      │ okay injury measure charge crane valley slice section wreck life     │
│               │ have acoustic water imitate can powder output ready crucial planet   │
│               │ bunker empower hard ready                                            │
├───────────────┼──────────────────────────────────────────────────────────────────────┤
│ Path          │ Seed wallet n. 2 (m/44'/4343'/1'/0'/0')                              │
└───────────────┴──────────────────────────────────────────────────────────────────────┘

SUCCESS Stored muemonic profile
(base) ~% 

こんな感じでさっきプライベートキーのところがMuemonicになってなんか単語が並んでる。

アカウントを復元する時にMnemonicも使えるのでこちらでもいいんちゃうんかな?

みたところ単なる単語の羅列やし。

分かる人には分かる暗号ぽいし。

かっこいいやん。

account info

そしたらaccount infoをみます。

account infoではオプションが設定できます。

どう言ったオプションが設定できるのか

symbol-cli account info --help

と叩いてみましょう。

スクリーンショット 2020-10-22 23.13.50.png


(base) ~% symbol-cli account info --help

  Get account information

  USAGE

    symbol-cli account info [...options]

  OPTIONS

    --profile <profile>     - (Optional) Select between your profiles, by providing a profile name.
    -a, --address <address> - Account address.                                                     

(base) ~% 

どっちの方がみやすい?

まぁそれはさておき

このOPTIONSのところで設定できるオプションは2つあります。

まずは--profile

これは

symbol-cli account info --profile プロファイル名

みたいな感じでします。

(base) ~% symbol-cli profile list

┌──────────────────┬──────────────────────────────────────────────────────────────────┐
│ Property         │ Value                                                            │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Name             │ Mickey Mouse                                                     │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address          │ TB24HF-CFTVKN-AMILBJ-WOEMPL-2KUAUS-A4MJKD-CGQ                    │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network          │ TEST_NET                                                         │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Node URL         │ http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000     │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Generation Hash  │ 6C1B92391CCB41C96478471C2634C111D9E989DECD66130C0430B5B8D20117CD │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network Currency │ name: symbol.xym, divisibility: 6                                │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Profile type     │ PrivateKey                                                       │
└──────────────────┴──────────────────────────────────────────────────────────────────┘
┌──────────────────┬──────────────────────────────────────────────────────────────────┐
│ Property         │ Value                                                            │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Name             │ kazumasa                                                         │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address          │ TDPHQF-2UXIBN-GJ2XCU-57PLG5-2COHZ3-EG7OBU-S2Y                    │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network          │ TEST_NET                                                         │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Node URL         │ http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000     │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Generation Hash  │ 6C1B92391CCB41C96478471C2634C111D9E989DECD66130C0430B5B8D20117CD │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network Currency │ name: symbol.xym, divisibility: 6                                │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Profile type     │ PrivateKey                                                       │
└──────────────────┴──────────────────────────────────────────────────────────────────┘
┌──────────────────┬──────────────────────────────────────────────────────────────────┐
│ Property         │ Value                                                            │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Name             │ muemonic                                                         │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address          │ TDHHPD-2SLKLH-SFWYVQ-CAF65H-IR4GTI-6GW6AW-UGQ                    │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network          │ TEST_NET                                                         │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Node URL         │ http://api-01.ap-northeast-1.0.10.0.x.symboldev.network:3000     │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Generation Hash  │ 6C1B92391CCB41C96478471C2634C111D9E989DECD66130C0430B5B8D20117CD │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Network Currency │ name: symbol.xym, divisibility: 6                                │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Profile type     │ HD                                                               │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│ Path             │ Path n. 2 (m/44'/4343'/1'/0'/0')                                 │
└──────────────────┴──────────────────────────────────────────────────────────────────┘
symbol-cli profile list

で確認したところデフォがミッキー
それ以外にかづまさとニーモニックがいます。

なのでかづまさでみたいと思います

(base) ~% symbol-cli account info --profile kazumasa
⠙ Processing
Account Information
┌───────────────────┬──────────────────────────────────────────────────────────────────┐
│ Property          │ Value                                                            │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address           │ TDPHQF-2UXIBN-GJ2XCU-57PLG5-2COHZ3-EG7OBU-S2Y                    │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address Height    │ 77196                                                            │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Public Key        │ 0000000000000000000000000000000000000000000000000000000000000000 │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Public Key Height │ 0                                                                │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Importance        │ 0                                                                │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Importance Height │ 0                                                                │
└───────────────────┴──────────────────────────────────────────────────────────────────┘ 
Balance Information
┌──────────────────┬─────────────────┬─────────────────┬───────────────────┐
│ Mosaic Id        │ Relative Amount │ Absolute Amount │ Expiration Height │
├──────────────────┼─────────────────┼─────────────────┼───────────────────┤
│ 5B66E76BECAD0860 │ 100             │ 100000000       │ Never             │
└──────────────────┴─────────────────┴─────────────────┴───────────────────┘ 
(base) ~% 

はい。アカウントの情報が取れました。

このアカウントインフォで取得できるのは以下のようらしいです。
Address
Address Height ブロックチェーンにはじめてアドレスが認識された時(何かしらトランザクションを受けた時)のブロック高
Public Key(公開鍵)
Public Key Height ブロックチェーンにはじめて公開鍵を認識された時(何らかのトランザクションを発生させた時)のブロック高
Importance
Importance Height(importanceを集計したときのブロック高)

ブロック高はブロックチェーンで何番目のブロックという意味だそうです。

なので以下をみると
アドレスは77196番目のブロックではじめて認識されたよ。

パブリックキーはまだ認識されてないよ。
インポータンスも認識されていないよ。

という感じです。

(base) ~% symbol-cli account info --profile kazumasa
⠙ Processing
Account Information
┌───────────────────┬──────────────────────────────────────────────────────────────────┐
│ Property          │ Value                                                            │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address           │ TDPHQF-2UXIBN-GJ2XCU-57PLG5-2COHZ3-EG7OBU-S2Y                    │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Address Height    │ 77196                                                            │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Public Key        │ 0000000000000000000000000000000000000000000000000000000000000000 │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Public Key Height │ 0                                                                │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Importance        │ 0                                                                │
├───────────────────┼──────────────────────────────────────────────────────────────────┤
│ Importance Height │ 0                                                                │
└───────────────────┴──────────────────────────────────────────────────────────────────┘ 
Balance Information
┌──────────────────┬─────────────────┬─────────────────┬───────────────────┐
│ Mosaic Id        │ Relative Amount │ Absolute Amount │ Expiration Height │
├──────────────────┼─────────────────┼─────────────────┼───────────────────┤
│ 5B66E76BECAD0860 │ 100             │ 100000000       │ Never             │
└──────────────────┴─────────────────┴─────────────────┴───────────────────┘ 
(base) ~% 

Balance Information
残高一覧

Mosaic Idはモザイクの種類、ここではsymbol.xym
Relative Amountはわかりやすい形100xym
Absolute AmountはRelativeの10の6乗した感じ
Expiration Heightはモザイクの有効期限(チェーンが生きている限りいつまでもある)ズッ友だよ。

が取れます。

さっきのprofileと違うところがたくさんあります。

プロファイルで取れるものとアカウントインフォで取れるものは違います。

なのでどっちを取ればいいのか、よく考えて使いましょう!!

終わり!!

良き開発ライフを・・・

3
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
3
1