Hyperledger Fabric is an open-source permissioned blockchain platform that is designed to support the creation of scalable and secure distributed applications. It is part of the Hyperledger project, which is an umbrella project under the Linux Foundation that is focused on the development of open-source blockchain technologies. Hyperledger Fabric is designed to be modular and configurable, allowing developers to choose the specific components and features that they need to build their applications. It includes a permissioned network of peer nodes, a consensus mechanism, a system for managing the permissions of the nodes in the network, a chaincode system for implementing smart contracts, and a data storage model. Hyperledger Fabric is a powerful and flexible platform for building distributed applications that are based on blockchain technology. It provides a robust and scalable foundation for a wide range of applications, from simple contract-based applications to more complex distributed applications.
Command-line Interface (CLI) API
The CLI API is an important tool for working with Hyperledger Fabric, as it provides a simple and intuitive interface for performing many of the common tasks that are required when working with the platform. It allows developers and administrators to quickly and easily perform a wide range of tasks, without having to write custom code.
Some of the key features of the CLI API in Hyperledger Fabric include:
- The ability to install and instantiate chaincodes on the network, allows developers to deploy and test their chaincodes quickly and easily.
- The ability to query the ledger, allows developers to view the current state of the ledger and the results of transactions that have been executed on the network.
- The ability to manage the membership and permissions of the nodes in the network, allows administrators to add and remove nodes and assign different roles to them.
- The ability to submit transactions to the network, allows developers to test their chaincodes and applications in a live environment.
How to use CLI API?
1. First, we need some environment variables, you can go to the test-network folder from fabric samples. If you don't know about the Hyperledger fabric test network, then refer to the article Hyperledger Fabric “Building Your First Network”
2. Then open your terminal and run these commands -
export PATH=${PWD}/../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=${PWD}/configtx
export VERBOSE=false
3. Then run the following command to view the all CLI commands that are currently available:
peer --help
4. The terminal will look like this after executing the following commands:
5. To know the version of the peer, use the following command:
peer version
6. The terminal will look like this after executing the following commands:
The peer command supports other subcommands, below are their description:
Command | Description |
---|
version | It displays the version of the peer node. |
node start | It starts the peer node. |
node status | It displays the current status of the peer node. |
node stop | It stops the peer node. |
network login | It is used to login into the Hyperledger Network. |
network list | It displays all the sets of Hyperledger Network. |
chaincode deploy | It is used to deploy a chaincode or smart contract to the Hyperledger Network channel. |
chaincode invoke | It is used to invoke and initialize the chaincode. |
chaincode query | It is used to make queries using any chaincode method. |
Working with Chaincode using CLI
One of the most useful uses of the CLI can be working the chaincodes. One can invoke and deploy the chaincodes using the CLI.
1. The command for deploying packaged chaincode will be:
peer lifecycle chaincode install chaincode_packagename.tar.gz
2. The terminal will look like this after executing the following command -
3. To invoke the chaincode the following command is used:
peer chaincode invoke -C $CHANNEL_NAME -n $CHAINCODE_NAME -c '{ "Args": ["MyContract:methodName", "{}"] }'
4. The actual command looks like this, for deploying a chaincode on test-network:
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile /home/satyajit/Documents/SE/Indriya/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n INDRIYA --peerAddresses localhost:7051 --tlsRootCertFiles /home/satyajit/Documents/SE/Indriya/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /home/satyajit/Documents/SE/Indriya/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"function":"initLedger","Args":[]}'
5. The terminal will look like this after executing the following command:
Similar Reads
What is OSI Model? - Layers of OSI Model The OSI (Open Systems Interconnection) Model is a set of rules that explains how different computer systems communicate over a network. OSI Model was developed by the International Organization for Standardization (ISO). The OSI Model consists of 7 layers and each layer has specific functions and re
13 min read
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
TCP/IP Model The TCP/IP model (Transmission Control Protocol/Internet Protocol) is a four-layer networking framework that enables reliable communication between devices over interconnected networks. It provides a standardized set of protocols for transmitting data across interconnected networks, ensuring efficie
7 min read
Types of Network Topology Network topology refers to the arrangement of different elements like nodes, links, or devices in a computer network. Common types of network topology include bus, star, ring, mesh, and tree topologies, each with its advantages and disadvantages. In this article, we will discuss different types of n
12 min read
Computer Network Tutorial A Computer Network is a system where two or more devices are linked together to share data, resources and information. These networks can range from simple setups, like connecting two devices in your home, to massive global systems, like the Internet. Below are the main components of a computer netw
7 min read
Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br
14 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Steady State Response In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We
9 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read