主頁 > 區塊鏈 > Hyperledger Fabric 環境搭建及Fabric 測驗網路使用(區塊鏈、聯盟鏈)

Hyperledger Fabric 環境搭建及Fabric 測驗網路使用(區塊鏈、聯盟鏈)

2021-08-06 08:19:26 區塊鏈

系統環境:

[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

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/292110.html

標籤:區塊鏈

上一篇:配置Bitcoin節點

下一篇:活動回顧 | 從《美國貨幣史》看,位元幣是更好的貨幣嗎?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • JAVA使用 web3j 進行token轉賬

    最近新學習了下區塊鏈這方面的知識,所學不多,給大家分享下。 # 1. 關于web3j web3j是一個高度模塊化,反應性,型別安全的Java和Android庫,用于與智能合約配合并與以太坊網路上的客戶端(節點)集成。 # 2. 準備作業 jdk版本1.8 引入maven <dependency> < ......

    uj5u.com 2020-09-10 03:03:06 more
  • 以太坊智能合約開發框架Truffle

    前言 部署智能合約有多種方式,命令列的瀏覽器的渠道都有,但往往跟我們程式員的風格不太相符,因為我們習慣了在IDE里寫了代碼然后打包運行看效果。 雖然現在IDE中已經存在了Solidity插件,可以撰寫智能合約,但是部署智能合約卻要另走他路,沒辦法進行一個快捷的部署與測驗。 如果團隊管理的區塊節點多、 ......

    uj5u.com 2020-09-10 03:03:12 more
  • 谷歌二次驗證碼成為區塊鏈專用安全碼,你怎么看?

    前言 谷歌身份驗證器,前些年大家都比較陌生,但隨著國內互聯網安全的加強,它越來越多地出現在大家的視野中。 比較廣泛接觸的人群是國際3A游戲愛好者,游戲盜號現象嚴重+國外賬號安全應用廣泛,這類游戲一般都會要求用戶系結名為“兩步驗證”、“雙重驗證”等,平臺一般都推薦用谷歌身份驗證器。 后來區塊鏈業務風靡 ......

    uj5u.com 2020-09-10 03:03:17 more
  • 密碼學DAY1

    目錄 ##1.1 密碼學基本概念 密碼在我們的生活中有著重要的作用,那么密碼究竟來自何方,為何會產生呢? 密碼學是網路安全、資訊安全、區塊鏈等產品的基礎,常見的非對稱加密、對稱加密、散列函式等,都屬于密碼學范疇。 密碼學有數千年的歷史,從最開始的替換法到如今的非對稱加密演算法,經歷了古典密碼學,近代密 ......

    uj5u.com 2020-09-10 03:03:50 more
  • 密碼學DAY1_02

    目錄 ##1.1 ASCII編碼 ASCII(American Standard Code for Information Interchange,美國資訊交換標準代碼)是基于拉丁字母的一套電腦編碼系統,主要用于顯示現代英語和其他西歐語言。它是現今最通用的單位元組編碼系統,并等同于國際標準ISO/IE ......

    uj5u.com 2020-09-10 03:04:50 more
  • 密碼學DAY2

    ##1.1 加密模式 加密模式:https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html ECB ECB : Electronic codebook, 電子密碼本. 需要加密的訊息按照塊密碼的塊大小被分為數個塊,并對每個塊進 ......

    uj5u.com 2020-09-10 03:05:42 more
  • NTP時鐘服務器的特點(京準電子)

    NTP時鐘服務器的特點(京準電子) NTP時鐘服務器的特點(京準電子) 京準電子官V——ahjzsz 首先對時間同步進行了背景介紹,然后討論了不同的時間同步網路技術,最后指出了建立全球或區域時間同步網存在的問題。 一、概 述 在通信領域,“同步”概念是指頻率的同步,即網路各個節點的時鐘頻率和相位同步 ......

    uj5u.com 2020-09-10 03:05:47 more
  • 標準化考場時鐘同步系統推進智能化校園建設

    標準化考場時鐘同步系統推進智能化校園建設 標準化考場時鐘同步系統推進智能化校園建設 安徽京準電子科技官微——ahjzsz 一、背景概述隨著教育事業的快速發展,學校建設如雨后春筍,隨之而來的學校教育、管理、安全方面的問題成了學校管理人員面臨的最大的挑戰,這些問題同時也是學生家長所擔心的。為了讓學生有更 ......

    uj5u.com 2020-09-10 03:05:51 more
  • 位元幣入門

    引言 位元幣基本結構 位元幣基礎知識 1)哈希演算法 2)非對稱加密技術 3)數字簽名 4)MerkleTree 5)哪有位元幣,有的是UTXO 6)位元幣挖礦與共識 7)區塊驗證(共識) 總結 引言 上一篇我們已經知道了什么是區塊鏈,此篇說一下區塊鏈的第一個應用——位元幣。其實先有位元幣,后有的區塊 ......

    uj5u.com 2020-09-10 03:06:15 more
  • 北斗對時服務器(北斗對時設備)電力系統應用

    北斗對時服務器(北斗對時設備)電力系統應用 北斗對時服務器(北斗對時設備)電力系統應用 京準電子科技官微(ahjzsz) 中國北斗衛星導航系統(英文名稱:BeiDou Navigation Satellite System,簡稱BDS),因為是目前世界范圍內唯一可以大面積提供免費定位服務的系統,所以 ......

    uj5u.com 2020-09-10 03:06:20 more
最新发布
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:46:47 more
  • Hyperledger Fabric 使用 CouchDB 和復雜智能合約開發

    在上個實驗中,我們已經實作了簡單智能合約實作及客戶端開發,但該實驗中智能合約只有基礎的增刪改查功能,且其中的資料管理功能與傳統 MySQL 比相差甚遠。本文將在前面實驗的基礎上,將 Hyperledger Fabric 的默認資料庫支持 LevelDB 改為 CouchDB 模式,以實作更復雜的資料... ......

    uj5u.com 2023-04-16 07:28:31 more
  • .NET Core 波場鏈離線簽名、廣播交易(發送 TRX和USDT)筆記

    Get Started NuGet You can run the following command to install the Tron.Wallet.Net in your project. PM> Install-Package Tron.Wallet.Net 配置 public reco ......

    uj5u.com 2023-04-14 08:08:00 more
  • DKP 黑客分析——不正確的代幣對比率計算

    概述: 2023 年 2 月 8 日,針對 DKP 協議的閃電貸攻擊導致該協議的用戶損失了 8 萬美元,因為 execute() 函式取決于 USDT-DKP 對中兩種代幣的余額比率。 智能合約黑客概述: 攻擊者的交易:0x0c850f,0x2d31 攻擊者地址:0xF38 利用合同:0xf34ad ......

    uj5u.com 2023-04-07 07:46:09 more
  • Defi開發簡介

    Defi開發簡介 介紹 Defi是去中心化金融的縮寫, 是一項旨在利用區塊鏈技術和智能合約創建更加開放,可訪問和透明的金融體系的運動. 這與傳統金融形成鮮明對比,傳統金融通常由少數大型銀行和金融機構控制 在Defi的世界里,用戶可以直接從他們的電腦或移動設備上訪問廣泛的金融服務,而不需要像銀行或者信 ......

    uj5u.com 2023-04-05 08:01:34 more
  • solidity簡單的ERC20代幣實作

    // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "hardhat/console.sol"; //ERC20 同質化代幣,每個代幣的本質或性質都是相同 //ETH 是原生代幣,它不是ERC20代幣, ......

    uj5u.com 2023-03-21 07:56:29 more
  • solidity 參考型別修飾符memory、calldata與storage 常量修飾符C

    在solidity語言中 參考型別修飾符(參考型別為存盤空間不固定的數值型別) memory、calldata與storage,它們只能修飾參考型別變數,比如字串、陣列、位元組等... memory 適用于方法傳參、返參或在方法體內使用,使用完就會清除掉,釋放記憶體 calldata 僅適用于方法傳參 ......

    uj5u.com 2023-03-08 07:57:54 more
  • solidity注解標簽

    在solidity語言中 注釋符為// 注解符為/* 內容*/ 或者 是 ///內容 注解中含有這幾個標簽給予我們使用 @title 一個應該描述合約/介面的標題 contract, library, interface @author 作者的名字 contract, library, interf ......

    uj5u.com 2023-03-08 07:57:49 more
  • 評價指標:相似度、GAS消耗

    【代碼注釋自動生成方法綜述】 這些評測指標主要來自機器翻譯和文本總結等研究領域,可以評估候選文本(即基于代碼注釋自動方法而生成)和參考文本(即基于手工方式而生成)的相似度. BLEU指標^[^?88^^?^]^:其全稱是bilingual evaluation understudy.該指標是最早用于 ......

    uj5u.com 2023-02-23 07:27:39 more
  • 基于NOSTR協議的“公有制”版本的Twitter,去中心化社交軟體Damus

    最近,一個幽靈,Web3的幽靈,在網路游蕩,它叫Damus,這玩意詮釋了什么叫做病毒式營銷,滑稽的是,一個Web3產品卻在Web2的產品鏈上瘋狂傳銷,各方大佬紛紛為其背書,到底發生了什么?Damus的葫蘆里,賣的是什么藥? 注冊和簡單實用 很少有什么產品在用戶注冊環節會有什么噱頭,但Damus確實出 ......

    uj5u.com 2023-02-05 06:48:39 more