Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build the environment of Hyperledger Fabric v1.2 of blockchain

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the block chain Hyperledger Fabric v1.2 environment how to build, the article introduces in great detail, has a certain reference value, interested friends must read it!

In 2015, the Linux Foundation launched the Hyperledger project with the goal of developing cross-industry blockchain technology.

The Hyperledger project does not only define a single blockchain standard, but also encourages collaboration in development zone blockchain technology through the power of the open source community. Hyperledger Fabric is a blockchain project in Hyperledger. Like other blockchain technologies, Hyperledger Fabric contains a ledger, uses smart contracts, and is a system that manages transactions through all participants.

> the biggest difference between Hyperledger Fabric and other blockchain systems is that it is private and licensed. Unlike opening an unlicensed network system to allow unknown participants to join the network (which requires a workload proof protocol to ensure the validity of the transaction and maintain the security of the network), Hyperledger Fabric registers all its members through Membership Service Provider (MSP). Hyperledger Fabric also provides several pluggable options. Account data can be stored in multiple formats, consensus mechanisms can be accessed or disconnected, and many different MSP are supported at the same time.

>

> Hyperledger Fabric provides the ability to create a channel, which allows participants to create a separate account book for the transaction. This feature becomes particularly important when some of the participants in the network are competitors. Because these participants do not want all transaction information-- such as specific price information provided to some customers-- to be made public to all participants in the network. Only participants in the same channel will own the account book in that channel, while other participants who are not in this channel will not see the account book.

Hyperledger Fabric is a platform that provides distributed ledger solutions.

Hyperledger Fabric is supported by a modular architecture with excellent confidentiality, scalability, flexibility and scalability

Hyperledger Fabric is designed to support direct plug and enable of different module components, and can adapt to a variety of complex scenarios in the economic ecosystem.

Hyperledger Fabric provides a unique scalable and extensible architecture, which is a significant difference between Hyperledger Fabric and other blockchain solutions. If you are planning to deploy an enterprise blockchain with a full review mechanism and an open source architecture, Hyperledger Fabric is a good starting point for you.

Refer to the official Chinese document of Hyperledger Fabric: [https://hyperledgercn.github.io/hyperledgerDocs/]

# 1. Prepare Linux system recommendation Ubuntu 16.04or 18.04

# 1.1. View apt source feeds

```bash

Vim / etc/apt/sources.list

`

```bash

/ / Beiyou Mirror Source

Deb http://mirrors.byrio.org/ubuntu/ bionic main restricted

Deb http://mirrors.byrio.org/ubuntu/ bionic-updates main restricted

Deb http://mirrors.byrio.org/ubuntu/ bionic universe

Deb http://mirrors.byrio.org/ubuntu/ bionic-updates universe

Deb http://mirrors.byrio.org/ubuntu/ bionic multiverse

Deb http://mirrors.byrio.org/ubuntu/ bionic-updates multiverse

Deb http://mirrors.byrio.org/ubuntu/ bionic-backports main restricted universe multiverse

Deb http://security.ubuntu.com/ubuntu bionic-security main restricted

Deb http://security.ubuntu.com/ubuntu bionic-security universe

Deb http://security.ubuntu.com/ubuntu bionic-security multiverse

/ / Ali Source

Deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

Deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

Deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

Deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

Deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

Deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

Deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

Deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

`

# 1.2 Update Source

```bash

Apt-get update & & apt-get upgrade

`

# 2. Install Golang

Go language Chinese official website: [https://studygolang.com/dl](https://studygolang.com/dl)

```bash

Cd $HOME/ & & wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz

/ / extract to / usr/local

Tar-C / usr/local-xzf go1.8.1.linux-amd64.tar.gz

/ / modify environment variables

Vim / etc/profile

/ / set the path of go

Export GOROOT=/usr/local/go

Export GOPATH=$HOME/go

Export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

/ / the environment variable takes effect

Source / etc/profile

/ / View go version

Go version

`

# 3. Install git, cURL, libltdl-dev

```bash

Apt-get-y install git

/ / View git version

Git-version

Apt-get-y install curl

/ / View curl version

Curl-version

Apt-get-y install libltdl-dev

`

# 4. Install Docker

```bash

/ / install the software package to allow apt to use remote libraries through HTTPS

Apt-get-y install apt-transport-https ca-certificates curl software-properties-common

/ / add the official GPG key of Docker

Curl-fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add-

/ / use the following command to set up a stable version of the remote library

Add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu

(lsb_release-cs) stable "

/ / update the apt package index again

Apt-get-y update

/ / install docker-ce using apt

Apt-get-y install docker-ce

/ / verify whether the installation is successful and view the version

Docker version

`

* Note: if the second order is executed, an error is reported *

! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545196.png)

# 5. Install python-pip, docker-compose

```bash

Apt- ­get-y install python ­- pip

/ / View pip version

Pip-V

Apt-get-y install docker ­- compose

/ / View docker-compose version

Docker ­- compose ­- ­version

`

# 6. Download fabric source code and Fabric-samples

# 6.1 manually create a new mkdir folder

```bash

/ / get fabirc and switch versions

Git clone https://gitee.com/arxin/fabric.git

/ / enter fabric

Cd / fabric

/ / View the existing version information

Git branch-a

/ / switch to version 1.2.0

Git checkout-b v1.2.0

/ / get fabric-samples and switch versions

Curl-sSL https://bit.ly/2ysbOFE | bash-s-1.2.0

`

* Note: if the execution is unsuccessful, choose accelerated link or use code cloud *

```bash

/ / accelerated address

Git clone https://github.com.cnpmjs.org/wlc1216/Hyperledger-fabric.git

/ / Code Cloud

Git clone https://gitee.com/arxin/fabric.git

`

# 6.2 View pull Image

```bash

Docker images

`

# 6.3 Network testing

```bash

/ / enter the first-network folder

Cd.. / fabric/fabric-samples/first-network

`

! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545197.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dsY18xMTEx,size_16,color_FFFFFF,t_70)

-.env: stores some environment variables

-base: some public services for storing docker-compose

-byfn.sh: execute script

-configtx.yaml and crypto-config.yaml: generate the corresponding configuration files based on the two tools generated previously, which are used to start the network and put them in the channel-artifacts and crypto-config of the current directory.

-dockper-compose: used to start the network

-scripts: store test scripts, what to do: create channels, add channels, install chain codes, instantiate chain codes, chain code interactions

```bash

/ / generate the required certificates and images

. / byfn.sh-m generate

/ / start the network

. / byfn.sh-m up

`

! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545198.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dsY18xMTEx,size_16,color_FFFFFF,t_70)

Wait.

! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545199.png)

All right! Congratulations on appearing this page, successful.

```bash

/ / shut down the network

. / byfn.sh-m down

`

* Note: docker-compose reported an error during network startup *! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545200.png)

The reason is that the reading time of compse is too short.

```bash

Vi / etc/resolv.conf

`

Solution: precede the line options timeout:2 attempts:3 rotate single-request-reopen with a pound sign and then save and exit.

# 7. Test the favirc network

In the official example, the name of channel is mychannel and the name of chain code is mycc

Use the docker exec command to enter the CLI container:

```bash

Docker exec-it cli bash

`

Under the / opt/gopath/src/github.com/hyperledger/fabric/peer directory, run the following command to query the balance of account a:

```bash

Peer chaincode query-C mychannel-n mycc-c'{"Args": ["query", "a"]}'

`

! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545201.png)

Below, we can transfer money. The operation is invoke, from a to b 20:

```bash

Peer chaincode invoke-o orderer.example.com:7050-- tls true-- cafile / opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem-C mychannel-n mycc-c'{"Args": ["invoke", "a", "b", "20"]}'

`

! [insert picture description here] (https://cache.yisu.com/upload/information/20210522/356/545202.png)

The transfer is successful!

* Note: about the successful transfer, but there is no synchronization problem *

The reason should be the strategy of endorsement. Both org should be endorsed and cannot be omitted.

AND ('Org1.member',' Org2.member', 'Org3.member') indicates that three subjects are required to sign and endorse.

OR ('Org1.member',' Org2.member') indicates that one of the two subjects is required to endorse the signature

OR ('Org1.member',AND (' Org2.member', 'Org3.member')) indicates the need for a signature endorsement by Org1 or a joint signature endorsement by Org2 and Org3

# 8. About node.js development

# 1. Install node.js and npm

```bash

Curl ­sL https://deb.nodesource.com/setup_8.x | sudo ­- E bash ­-

/ / View node version

Node-v

/ / View npm version

Npm ­- v

`

# 1.1 move to the fabcar directory

```bash

Cd.. /

Cd fabcar

`

# 1.2 install node module

```bash

Npm install

`

* Note: there may be a problem with the node.js version, please try to upgrade *

Npm upgrade or update to the specified version, run the instruction

```bash

Npm install-g npm or npm-g install npm@3.0.0

`

# 1.3 install the grpc module to communicate with Hyperledger Fabric:

```bash

Sudo npm install grpc

`

# 1.4 launch the Hyperledger Fabric network of fabcar

```bash

. / startFabric.sh

`

These are all the contents of this article entitled "how to build the Environment of Block chain Hyperledger Fabric v1.2". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report