0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Hyperledger Irohaでアカウントを作成する

Posted at

記事の内容

Irohaのドキュメントや環境構築してみたというような記事では「iroha-cli -new_account」を使ってアカウントを作成するというところまで書かれてある記事を目にします。

ここまでの内容では、Interactiveモードでアカウント情報を照会すると「Account not Found」となってしまうので、調べた方法を残します。

#アカウントの作成方法

キー情報を作成する

まずは「user@test」というユーザーを作ってみます。

root@c3d22eb8a2bb:/opt/iroha_data# iroha-cli -new_account -account_name user@test -pass_phrase user
[2019-10-13 10:19:48.650228426][I][CLI/Main]: Public and private key has been generated in current directory
root@c3d22eb8a2bb:/opt/iroha_data# ls
README.md        bk                 config.sample  genesis.block       iroha@iroha.priv  iroha@test.pub  python          torii_tls
admin@test.priv  config-win.sample  core.10090     hiroha@hiroha.priv  iroha@iroha.pub   node0.priv      test@test.priv  user@test.priv
admin@test.pub   config.docker      core.9348      hiroha@hiroha.pub   iroha@test.priv   node0.pub       test@test.pub   user@test.pub
root@c3d22eb8a2bb:/opt/iroha_data#

この時点でアカウント情報を照会してもアカウントは見つかりません。(Account not found)

root@c3d22eb8a2bb:/opt/iroha_data# iroha-cli -account_name admin@test
Welcome to Iroha-Cli.
Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 2
Choose query:
1. Get all permissions related to role (get_role_perm)
2. Get Transactions by transactions' hashes (get_tx)
3. Get information about asset (get_ast_info)
4. Get Account's Transactions (get_acc_tx)
5. Get Account's Asset Transactions (get_acc_ast_tx)
6. Get all current roles in the system (get_roles)
7. Get Account's Signatories (get_acc_sign)
8. Get Account's Assets (get_acc_ast)
9. Get Account Information (get_acc)
0. Back (b)
> : 9
Requested account Id: user@test
Query is formed. Choose what to do:
1. Send to Iroha peer (send)
2. Save as json file (save)
0. Back (b)
> : 1
Peer address (0.0.0.0): localhost
Peer port (50051): 50051
[2019-10-13 10:22:21.843534603][E][CLI/ResponseHandler/Query]: Account not found

対話形式でアカウント情報を登録する

まずは、公開鍵を確認します。

root@c3d22eb8a2bb:/opt/iroha_data# cat user@test.pub
0107259f0fbd19354f9a1d2e2caf15204dde10e8bf9bd1d1c44b601c58d60718

対話形式で登録していきます。

root@c3d22eb8a2bb:/opt/iroha_data# iroha-cli -account_name admin@test
Welcome to Iroha-Cli.
Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 1
Forming a new transactions, choose command to add:
1. Detach role from account (detach)
2. Add new role to account (apnd_role)
3. Create new role (crt_role)
4. Set account key/value detail (set_acc_kv)
5. Transfer Assets (tran_ast)
6. Grant permission over your account (grant_perm)
7. Subtract Assets Quantity (sub_ast_qty)
8. Set Account Quorum (set_qrm)
9. Remove Signatory (rem_sign)
10. Create Domain (crt_dmn)
11. Revoke permission from account (revoke_perm)
12. Create Account (crt_acc)
13. Add Signatory to Account (add_sign)
14. Create Asset (crt_ast)
15. Add Peer to Iroha Network (add_peer)
16. Add Asset Quantity (add_ast_qty)
0. Back (b)
> : 12
Account Name: user
Domain Id: test
Public Key: 0107259f0fbd19354f9a1d2e2caf15204dde10e8bf9bd1d1c44b601c58d60718
Command is formed. Choose what to do:
1. Add one more command to the transaction (add)
2. Send to Iroha peer (send)
3. Go back and start a new transaction (b)
4. Save as json file (save)
> : 2
Peer address (0.0.0.0): localhost
Peer port (50051): 50051
[2019-10-13 10:25:57.336240623][I][CLI/ResponseHandler/Transaction]: Transaction successfully sent
Congratulation, your transaction was accepted for processing.
Its hash is 11c7d1dee6516dd6ea72f5b2761d756c47e9d2337783917e555718d2ccf596df

登録出来ました。
アカウント情報を照会します。

Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 2
Choose query:
1. Get all permissions related to role (get_role_perm)
2. Get Transactions by transactions' hashes (get_tx)
3. Get information about asset (get_ast_info)
4. Get Account's Transactions (get_acc_tx)
5. Get Account's Asset Transactions (get_acc_ast_tx)
6. Get all current roles in the system (get_roles)
7. Get Account's Signatories (get_acc_sign)
8. Get Account's Assets (get_acc_ast)
9. Get Account Information (get_acc)
0. Back (b)
> : 9
Requested account Id: user@test
Query is formed. Choose what to do:
1. Send to Iroha peer (send)
2. Save as json file (save)
0. Back (b)
> : 1
Peer address (0.0.0.0): localhost
Peer port (50051): 50051
[2019-10-13 10:28:17.299491379][I][CLI/ResponseHandler/Query]: [Account]:
[2019-10-13 10:28:17.299509542][I][CLI/ResponseHandler/Query]: -Account Id:- user@test
[2019-10-13 10:28:17.299513322][I][CLI/ResponseHandler/Query]: -Domain- test
[2019-10-13 10:28:17.299516559][I][CLI/ResponseHandler/Query]: -Roles-:
[2019-10-13 10:28:17.299520303][I][CLI/ResponseHandler/Query]:  user
[2019-10-13 10:28:17.299523774][I][CLI/ResponseHandler/Query]: -Data-: {}

無事、情報を取得出来ました。

アカウント作成時のブロック情報はこのようになっています。

{
  "blockV1": {
    "payload": {
      "transactions": [
        {
          "payload": {
            "reducedPayload": {
              "commands": [
                {
                  "createAccount": {
                    "accountName": "user",
                    "domainId": "test",
                    "publicKey": "0107259f0fbd19354f9a1d2e2caf15204dde10e8bf9bd1d1c44b601c58d60718"
                  }
                }
              ],
              "creatorAccountId": "admin@test",
              "createdTime": "1570962357312",
              "quorum": 1
            }
          },
          "signatures": [
            {
              "publicKey": "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910",
              "signature": "355d24ea18e75933c6edc336b135892b538d1c2ad9ae011331fd7c47ddda219060b3a6c60b3e68aca1858179ea2a63d32f7a6ad6a14e94569207083f4dcbff0a"
            }
          ]
        }
      ],
      "height": "11",
      "prevBlockHash": "14dea76870399866b4fc1bc2bf1698713d831fdec80ba0a7c482829a25b9b1d7",
      "createdTime": "1570962359411"
    },
    "signatures": [
      {
        "publicKey": "bddd58404d1315e0eb27902c5d7c8eb0602c16238f005773df406bc191308929",
        "signature": "4c61e8be7560ceb84a5d922c489cd0b2e94850902e9f12cfcd05f45ca80cd4909ebff661debd38150dd67a696566f3d3a478e702f137ba6fee1ec1ed3144380c"
      }
    ]
  }
}
0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?