IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 区块链 -> Hyperledger Fabric 环境搭建及Fabric 测试网络使用(区块链、联盟链) -> 正文阅读

[区块链]Hyperledger Fabric 环境搭建及Fabric 测试网络使用(区块链、联盟链)

系统环境:

[root@localhost ~]# cat /proc/version
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020

官网手册:

https://www.hyperledger.org/use/fabric

环境搭建

一、基础软件安装

# 安装Git(Git是一个免费的、开源的分布式版本控制系统)
  # https://git-scm.com/downloads
[root@localhost ~]# yum install git
# 验证
[root@localhost ~]# git version
git version 1.8.3.1

安装cURL

cURL是一个利用URL语法在命令行下工作的文件传输工具,它支持文件上传和下载,所以是综合传输工具

  # https://curl.haxx.se/download.html
[root@localhost ~]# yum install curl
# 验证
[root@localhost ~]# curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets

安装Docker(Docker Engine)

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows 机器上,也可以实现虚拟化

   # https://docs.docker.com/get-docker/
Docker引擎(Docker Engine)安装请参考该教程:https://blog.csdn.net/Bjxhub/article/details/119352882
# 关键命令
[root@localhost ~]# sudo yum install docker-ce docker-ce-cli containerd.io

# 确认安装后的docker版本
[root@localhost ~]# docker --version
Docker version 20.10.7, build f0df350

# Docker Compose 依赖 Docker Engine 进行任何有意义的工作,因此请确保根据您的设置,在本地或远程安装了 Docker Engine。
# 使用 Docker Compose 可以轻松、高效的管理容器,它是一个用于定义和运行多容器 Docker 的应用程序工具
Docker Compose安装官方教程:https://docs.docker.com/compose/install/
# 下载docker-compose,建议关闭防火墙,否则报错:curl: (35) Encountered end of file
[root@localhost ~]# systemctl stop firewalld    
[root@localhost ~]#
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 赋权
[root@localhost ~]# sudo chmod +x /usr/local/bin/docker-compose
# 验证
[root@localhost ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
#Docker引擎(Docker Engine)与Docker Compose的版本(此处均取最新)对应关系:
  https://docs.docker.com/compose/compose-file/compose-versioning/
# 启动
[root@localhost ~]# sudo systemctl start docker
# 开机启动
[root@localhost ~]# sudo systemctl enable docker

安装Go

Google 的 Robert Griesemer,Rob Pike 及 Ken Thompson 开发的一种静态强类型、编译型语言
##!!!!----若Go与Jq无法安装,则需添加安装源:[[root@localhost ~]# yum install epel-release]----!!!!!

# https://golang.org/doc/install(国内无法访问)
[root@localhost ~]# yum install go
# 验证
[root@localhost ~]# go version
go version go1.15.5 linux/amd64

安装JQ

jq是一个轻量级且灵活的命令行JSON处理器

# https://stedolan.github.io/jq/download/
[root@localhost ~]# yum install jq
# 验证
[root@localhost ~]# jq --version
jq-1.6

二、 安装 Fabric 和 Fabric 示例

2.1 自动搭建(不推荐,国内基本不成功,推荐直接进入2.2 手动搭建)


# 创建一个工作目录并进入
[root@localhost ~]# mkdir -p mkdir -p $HOME/go/src/github.com/fabric
[root@localhost ~]# cd $HOME/go/src/github.com/fabric

# 查看当前全路径
[root@localhost fabric]# pwd
/root/go/src/github.com/fabric

# 方式一: 执行自动搭建脚本(不推荐)
# !!!!自动下载最新版本的 Fabric 示例、docker 镜像和二进制文件。!!!!
[root@localhost fabric]#  curl -sSL https://bit.ly/2ysbOFE | bash -s

# 方式二: 更换脚本地址再执行(不推荐)
若上述命令报错:curl: (35) Encountered end of file
原因:命令中的https://bit.ly/2ysbOFE在国内无法访问,
     官方给出了可在国内可访问的新地址:https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh
解决方案:执行如下自动搭建命令(需要一个漫长的等待~)
[root@localhost fabric]# curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh| bash -s 

Clone hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo
正克隆到 'fabric-samples'...
error: RPC failed; result=35, HTTP code = 0
fatal: The remote end hung up unexpectedly
fabric-samples v2.3.2 does not exist, defaulting main
fatal: Not a git repository (or any of the parent directories): .git

Pull Hyperledger Fabric binaries

===> Downloading version 2.3.2 platform specific fabric binaries
===> Downloading:  https://github.com/hyperledger/fabric/releases/download/v2.3.2/hyperledger-fabric-linux-amd64-2.3.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 73.5M  100 73.5M    0     0  75919      0  0:16:56  0:16:56 --:--:-- 98853
==> Done.
===> Downloading version 1.5.0 platform specific fabric-ca-client binary
===> Downloading:  https://github.com/hyperledger/fabric-ca/releases/download/v1.5.0/hyperledger-fabric-ca-linux-amd64-1.5.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
curl: (35) Encountered end of file

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
==> There was an error downloading the binary file.
------> 1.5.0 fabric-ca-client binary is not available to download  (Available from 1.1.0-rc1) <----


<—!!!—>
若想继续自动搭建,参考教程:https://blog.csdn.net/mutou___/article/details/109849720
<—!!!—>

2.2 手动搭建搭建(推荐)

Step1、下载fabric源码

# 进入之前创建的工作目录
[root@localhost ~]# cd $HOME/go/src/github.com/fabric

# !!不推荐该获取方式
[root@localhost fabric]#  git clone https://github.com/hyperledger/fabric.git
# 注意:这一步下载会很慢,可以使用科学上网方法
# 也可以使用Chrome浏览器中GitHub加速插件,下面使用加速插件连接替换

# !!!!推荐以下获取方式:
# 以下代码执行其中一行即可。
git clone https://hub.fastgit.org/hyperledger/fabric.git
# or
git clone https://github.com.cnpmjs.org/hyperledger/fabric.git
# or
git clone https://github.91chifun.workers.dev//https://github.com/hyperledger/fabric.git

Step2、下载Docker镜像

[root@localhost fabric]# cd fabric/scripts/
[root@localhost scripts]# sudo ./bootstrap.sh -b -s
......
===> List out hyperledger docker images
hyperledger/fabric-tools     2.3       a206a1593b4c   3 months ago   448MB
hyperledger/fabric-tools     2.3.2     a206a1593b4c   3 months ago   448MB
hyperledger/fabric-tools     latest    a206a1593b4c   3 months ago   448MB
hyperledger/fabric-peer      2.3       85c825d4769f   3 months ago   54.2MB
hyperledger/fabric-peer      2.3.2     85c825d4769f   3 months ago   54.2MB
hyperledger/fabric-peer      latest    85c825d4769f   3 months ago   54.2MB
hyperledger/fabric-orderer   2.3       7cad713cbfea   3 months ago   37.8MB
hyperledger/fabric-orderer   2.3.2     7cad713cbfea   3 months ago   37.8MB
hyperledger/fabric-orderer   latest    7cad713cbfea   3 months ago   37.8MB
hyperledger/fabric-ccenv     2.3       627c556b15ca   3 months ago   514MB
hyperledger/fabric-ccenv     2.3.2     627c556b15ca   3 months ago   514MB
hyperledger/fabric-ccenv     latest    627c556b15ca   3 months ago   514MB
hyperledger/fabric-baseos    2.3       e50ea411d694   3 months ago   6.86MB
hyperledger/fabric-baseos    2.3.2     e50ea411d694   3 months ago   6.86MB
hyperledger/fabric-baseos    latest    e50ea411d694   3 months ago   6.86MB
hyperledger/fabric-ca        1.5       24a7c19a9fd8   4 months ago   70.8MB
hyperledger/fabric-ca        1.5.0     24a7c19a9fd8   4 months ago   70.8MB
hyperledger/fabric-ca        latest    24a7c19a9fd8   4 months ago   70.8MB

Step3、下载fabric-samples

[root@localhost scripts]# git clone https://hub.fastgit.org/hyperledger/fabric-samples.git

正克隆到 'fabric-samples'...
remote: Enumerating objects: 7662, done.
remote: Counting objects: 100% (129/129), done.
remote: Compressing objects: 100% (99/99), done.
remote: Total 7662 (delta 48), reused 74 (delta 27), pack-reused 7533
接收对象中: 100% (7662/7662), 4.37 MiB | 1.08 MiB/s, done.
处理 delta 中: 100% (3974/3974), done.

Step4、下载二进制文件

[root@localhost scripts]# cat bootstrap.sh

# 查看以下版本信息
# if version not passed in, default to latest released version
VERSION=2.3.2
# if ca version not passed in, default to latest released version
CA_VERSION=1.5.0

#
[root@localhost scripts]# cd /opt

# 因需要用到wget命令,未安装的需要安装,也可以采用手动下载再上传的方式。
[root@localhost opt]# yum install wget

# 下载hyperledger-fabric-linux-amd64-2.3.0.tar.gz
[root@localhost opt]# wget https://github.91chifun.workers.dev//https://github.com/hyperledger/fabric/releases/download/v2.3.2/hyperledger-fabric-linux-amd64-2.3.2.tar.gz
# 下载hyperledger-fabric-ca-linux-amd64-1.4.9.tar.gz
[root@localhost opt]# wget https://github.91chifun.workers.dev//https://github.com/hyperledger/fabric-ca/releases/download/v1.5.0/hyperledger-fabric-ca-linux-amd64-1.5.0.tar.gz

# 查看已下载压缩包
[root@localhost opt]# ls
containerd  hyperledger-fabric-ca-linux-amd64-1.5.0.tar.gz  hyperledger-fabric-linux-amd64-2.3.2.tar.gz

# 解压(两个压缩文件解压出 bin/ config/ 两个目录,两个目录应位于fabric-samples之下~)
[root@localhost opt]# tar -zxvf hyperledger-fabric-linux-amd64-2.3.2.tar.gz  -C $HOME/go/src/github.com/fabric/fabric/scripts/fabric-samples/
[root@localhost opt]# tar -zxvf hyperledger-fabric-ca-linux-amd64-1.5.0.tar.gz -C $HOME/go/src/github.com/fabric/fabric/scripts/fabric-samples/
#

其他参考链接:

Ubuntu 系统环境手动安装:https://blog.csdn.net/mutou___/article/details/109986259

三、 启动测试网络

# 进入test-network目录
[root@localhost test-network]# cd $HOME/go/src/github.com/fabric/fabric/scripts/fabric-samples/test-network
# 删除先前可能运行的网络
[root@localhost test-network]# ./network.sh down
Stopping network
Stopping cli                    ... done
Stopping orderer.example.com    ... done
Stopping peer0.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Removing cli                    ... done
Removing orderer.example.com    ... done
Removing peer0.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing network fabric_test
Removing volume docker_orderer.example.com
Removing volume docker_peer0.org1.example.com
Removing volume docker_peer0.org2.example.com
WARNING: The DOCKER_SOCK variable is not set. Defaulting to a blank string.
Removing network fabric_test
WARNING: Network fabric_test not found.
Removing volume docker_peer0.org3.example.com
WARNING: Volume docker_peer0.org3.example.com not found.
Removing remaining containers
Removing generated chaincode docker images

# 执行./network.sh up 前,建议重启下Docker容器,
否则可能会报错:
ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule:  (iptables failed: iptables --wait -t nat -I DOCKER -i br-10eb04b81c62 -j RETURN: iptables: No chain/target/match by that name.
[root@localhost test-network]# systemctl restart  docker
# 如仍未解决,请尝试关闭防火墙:
[root@localhost test-network]# systemctl stop firewalld

# 启动测试网络
[root@localhost test-network]# ./network.sh up
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.3.2
DOCKER_IMAGE_VERSION=2.3.2
/root/go/src/github.com/fabric/fabric/scripts/fabric-samples/bin/cryptogen
Generating certificates using cryptogen tool
Creating Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Creating Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Creating Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generating CCP files for Org1 and Org2
Creating network "fabric_test" with the default driver
Creating volume "docker_orderer.example.com" with default driver
Creating volume "docker_peer0.org1.example.com" with default driver
Creating volume "docker_peer0.org2.example.com" with default driver
Creating orderer.example.com    ... done
Creating peer0.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating cli                    ... done
CONTAINER ID   IMAGE                               COMMAND             CREATED                  STATUS                  PORTS                                                                                                                                 NAMES
c231a061efeb   hyperledger/fabric-tools:latest     "/bin/bash"         Less than a second ago   Up Less than a second                                                                                                                                         cli
d8105d031285   hyperledger/fabric-orderer:latest   "orderer"           2 seconds ago            Up Less than a second   0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp, 0.0.0.0:17050->17050/tcp, :::17050->17050/tcp   orderer.example.com
13ebc165136a   hyperledger/fabric-peer:latest      "peer node start"   2 seconds ago            Up Less than a second   0.0.0.0:7051->7051/tcp, :::7051->7051/tcp, 0.0.0.0:17051->17051/tcp, :::17051->17051/tcp                                              peer0.org1.example.com
e77cc6055337   hyperledger/fabric-peer:latest      "peer node start"   2 seconds ago            Up Less than a second   0.0.0.0:9051->9051/tcp, :::9051->9051/tcp, 7051/tcp, 0.0.0.0:19051->19051/tcp, :::19051->19051/tcp                                    peer0.org2.example.com

# 网络启动验证,可查看启动了以下几个模拟网络的容器:
# 测试网络包括两个对等组织,Org1 和 Org2。它还包括一个维护网络订购服务的单一订购者组织。
[root@localhost test-network]# docker ps
CONTAINER ID   IMAGE                               COMMAND             CREATED          STATUS          PORTS                                                                                                                                 NAMES
c231a061efeb   hyperledger/fabric-tools:latest     "/bin/bash"         49 seconds ago   Up 48 seconds                                                                                                                                         cli
d8105d031285   hyperledger/fabric-orderer:latest   "orderer"           51 seconds ago   Up 49 seconds   0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp, 0.0.0.0:17050->17050/tcp, :::17050->17050/tcp   orderer.example.com
13ebc165136a   hyperledger/fabric-peer:latest      "peer node start"   51 seconds ago   Up 49 seconds   0.0.0.0:7051->7051/tcp, :::7051->7051/tcp, 0.0.0.0:17051->17051/tcp, :::17051->17051/tcp                                              peer0.org1.example.com
e77cc6055337   hyperledger/fabric-peer:latest      "peer node start"   51 seconds ago   Up 49 seconds   0.0.0.0:9051->9051/tcp, :::9051->9051/tcp, 7051/tcp, 0.0.0.0:19051->19051/tcp, :::19051->19051/tcp                                    peer0.org2.example.com

四、 创建频道(channel)

# 默认 为mychannel,可以自定义channel名:./network.sh createChannel -c <自定义Channel名>
[root@localhost test-network]# ./network.sh createChannel
Creating channel 'mychannel'.
If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb
Generating channel genesis block 'mychannel.block'
/root/go/src/github.com/fabric/fabric/scripts/fabric-samples/bin/configtxgen
.......
2021-08-05 05:31:24.428 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-08-05 05:31:24.442 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org2MSP' on channel 'mychannel'
Channel 'mychannel' joined

五、 启用链码(chaincode)

# 在启用码链前,需要更改go代理,确保启用成功。
否则,会报如下错误:
......
Error: failed to normalize chaincode path: 'go list' failed with: : signal: killed
Chaincode packaging has failed
Deploying chaincode failed

[root@localhost test-network]# go env -w GOPROXY=https://goproxy.io,direct
[root@localhost test-network]# go env -w GO111MODULE=on

# deployCC子命令将在peer0.org1.example.com和peer0.org2.example.com上安装资产转移(基本)链码,然后在使用通道标志指定的通道上部署链码(如果未指定通道,则在mychannel上部署)。
[root@localhost test-network]# ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
deploying chaincode on channel 'mychannel'
executing with the following
......
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org2 on channel 'mychannel'
Chaincode initialization is not required

六、 与网络互动(peer)

# <!--1、进入工作目录--!>
# 确保您从test-network目录中操作
# 进入test-network目录
[root@localhost ~]# cd $HOME/go/src/github.com/fabric/fabric/scripts/fabric-samples/test-network

# <!--2、添加环境变量--!>
#  添加二进制文件的环境变量
[root@localhost test-network]# export PATH=${PWD}/../bin:$PATH
# FABRIC_CFG_PATH
[root@localhost test-network]# export FABRIC_CFG_PATH=$PWD/../config/

# <!--3、Org1环境变量设置--!>
# 设置允许peer以Org1身份操作CLI的环境变量:
[root@localhost test-network]# export CORE_PEER_TLS_ENABLED=true
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org1MSP"
[root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
[root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
[root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:7051

# <!--4、Org1初始化分类账--!>
# 使用资产初始化分类账( initialize the ledger with assets)
[root@localhost test-network]# peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"InitLedger","Args":[]}'
2021-08-05 15:53:20.773 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200

# <!--4、Org1获取分类账的资产列表--!>
# 获取添加到渠道分类账的资产列表(get the list of assets that were added to your channel ledger)
[root@localhost test-network]# peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
[{"ID":"asset1","color":"blue","size":5,"owner":"Tomoko","appraisedValue":300},{"ID":"asset2","color":"red","size":5,"owner":"Brad","appraisedValue":400},{"ID":"asset3","color":"green","size":10,"owner":"Jin Soo","appraisedValue":500},{"ID":"asset4","color":"yellow","size":10,"owner":"Max","appraisedValue":600},{"ID":"asset5","color":"black","size":15,"owner":"Adriana","appraisedValue":700},{"ID":"asset6","color":"white","size":15,"owner":"Michel","appraisedValue":800}]

# <!--5、Org1修改账本上资产的所有者--!>
# 通过调用资产转移(基本)链代码来更改账本上资产的所有者(change the owner of an asset on the ledger by invoking the asset-transfer (basic) chaincode)
[root@localhost test-network]# peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"TransferAsset","Args":["asset6","Christopher"]}'
2021-08-05 15:58:26.650 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200

# <!--6、Org2环境变量设置--!>
# 设置允许peer以Org2身份操作CLI的环境变量:
[root@localhost test-network]# export CORE_PEER_TLS_ENABLED=true
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org2MSP"
[root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
[root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
[root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:9051

# <!--7、Org2查询分类账的资产(asset6)--!>
# 查询在peer0.org2.example.com上运行的资产转移(基本)链代码
# query the asset-transfer (basic) chaincode running on peer0.org2.example.com
[root@localhost test-network]# peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
{"ID":"asset6","color":"white","size":15,"owner":"Christopher","appraisedValue":800}

#关闭网络
[root@localhost test-network]# ./network.sh down
  区块链 最新文章
盘点具备盈利潜力的几大加密板块,以及潜在
阅读笔记|让区块空间成为商品,打造Web3云
区块链1.0-比特币的数据结构
Team Finance被黑分析|黑客自建Token“瞒天
区块链≠绿色?波卡或成 Web3“生态环保”标
期货从入门到高深之手动交易系列D1课
以太坊基础---区块验证
进入以太坊合并的五个数字
经典同态加密算法Paillier解读 - 原理、实现
IPFS/Filecoin学习知识科普(四)
上一篇文章      下一篇文章      查看所有文章
加:2021-08-05 17:24:43  更:2021-08-05 17:24:53 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 10:36:52-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码