Overview

Skill Level: Intermediate

In this recipe, we explore Hyperledger Indy Command Line Interface by creating and listing the wallet, importing and using decentralized identifier and creating and listing hyperledger indy node pool.

Ingredients

To follow and complete this recipe, you need to have good knowledge of blockchain, Hyperledger transactions, JavaScript as well as basic knowledge of Linux.

Step-by-step

  1. Hyperledger Indy Overview

    Hyperledger Indy is a distributed ledger in The Linux Foundation family which is built for decentralized digital-identity management. Hyperledger Indy is in its incubation stage so in this recipe we will explore the Indy Command Line Interface or CLI to look at the concept and functions offered by Hyperledger Indy with the current distribution. For those who are not familiar with Hyperledger project Intro to Hyperledger Family and Hyperledger Blockchain Ecosystem and Hyperledger Design Philosophy and Framework Architecture articles are strongly recommended.

    To better follow and understand this tutorial, it is advisable to read and follow Install Hyperledger Indy on AWS  and Exploring Indy CLI with Hyperledger Indy recipes in advance.
    In this recipe, we run Hyperledger Indy and explore it’s the power of its CLI by creating, opening, and listing the wallet, creating, importing, and using decentralized identifier or DID and creating, connecting, and listing hyperledger indy node pool.

  2. Run Hyperledger Indy Docker Container

    If the Indy Docker container is stopped, use the following command to start the Indy Docker container:
    ubuntu@ip-172-31-90-67:~/indy/indy-sdk$ sudo docker start stoic_mendeleev

  3. Running Hyperledger Indy CLI

    In the indy-sdk directory, run indy-cli, as follows:

    ubuntu@ip-172-31-90-67:~/indy/indy-sdk$ indy-cli indy>

    Creating, Opening, and Listing the Wallet

     

  4. Creating, Opening, and Listing the Wallet

    Execute the following steps:

    1. Create the wallet:

    indy> wallet create mywallet key

    Enter value for key:

    Wallet “mywallet” has been created

    2. Open the wallet:

    indy> wallet open mywallet key

    Enter value for key:

    Wallet “mywallet” has been opened

    wallet(mywallet):indy>

    3. List the wallet:

    wallet(mywallet):indy> wallet list

    +———-+———+

    | Name | Type |

    +———-+———+

    | mywallet | default |

    +———-+———+

    Current wallet “mywallet”

  5. Creating, Importing, and Using DID

    Execute the following steps:
    1. Import the predefined Steward DID from the sandbox testing network domain genesis file, domain_transactions_genesis. The admindid.txt import file is as follows:

    {

    “version”: 1,

    “dids”: [{

    “did”: “Th7MpTaRZVRYnPiabds81Y”,

    “seed”: “000000000000000000000000Steward1”

    }]

    }

    2. Import the predefined Steward DID for the sandbox testing network:
    wallet(mywallet):indy> did import /home/ubuntu/indy/indy-sdk/admindid.txt

    Did “Th7MpTaRZVRYnPiabds81Y” has been created with “~7TYfekw4GUagBnBVCqPjiC” verkey DIDs import finished

    3. Create a new DID:
    wallet(mywallet):indy> did new

    Did “JRAoDbiV2tRfWSL3jcRKCk” has been created with “~6iKD9dkZEypiugWbDEHsXw” verkey

    4. List the DID in the wallet:

    wallet(mywallet):indy> did List
    +———————— +————————- +———- +
    | Did | Verkey | Metadata |
    +———————— +————————- +———- +
    | JRAoDbiV2tRfWSL3jcRKCk | ~6iKD9dkZEypiugWbDEHsXw | – |
    +———————— +————————- +———- +
    | Th7MpTaRZVRYnPiabds81Y | ~7TYfekw4GUagBnBVCqPjiC | – |

    5. Specify the identity that was used to send a transaction request to the Indy network. To do this, you can enter the following command:

    wallet(mywallet):indy> did use Th7MpTaRZVRYnPiabds81Y Did “Th7MpTaRZVRYnPiabds81Y” has been set as active wallet(mywallet):did(Th7…81Y):indy>

  6. Creating, Connecting, and Listing Hyperledger Indy Node Pool

    Execute the following steps:

    1. Create the Indy pool configuration on the CLI using the genesis file for the sandbox testing network:

    wallet(mywallet):did(Th7…81Y):indy>pool create sandbox

    gen_txn_file=

    /home/ubuntu/indy/indy_sdk/cli/docker_pool_transactions_genesis

    Pool config “sandbox” has been created

    2. To connect the Indy CLI to the created Indy pool’s sandbox, use the following command:

    wallet(mywallet):did(Th7…81Y):indy> pool connect sandbox Pool “sandbox” has been connected

    3. List the pool in the CLI using the pool list command:

    pool(sandbox):wallet(mywallet):did(Th7…81Y):indy> pool list
    +———+
    | Pool |
    +———+
    | sandbox |
    +———+
    Current pool “sandbox”

    To recap, in this recipe you learned the following:

    • Run Hyperledger Indy Docker Container
    • Running Hyperledger Indy Command Line Interface or CLI
    • Creating, Opening, and Listing the Wallet
    • Creating, Importing, and Using DID or Decentralized Identifier
    • Creating, Connecting, and Listing Hyperledger Indy Node Pool

    The next steps are to work on i- Sending NYM transactions to the ledger and ii-Posting the credential schema and credential definition transaction to the ledger.

    This recipe is written in collaboration with Brian Wu who is a senior Hyperledger instructor at Coding Bootcamps school in Washington DC.

Join The Discussion