一、安装ubuntu20

Download Ubuntu Desktop | Download | Ubuntu

二、安装环境

参考:

Prerequisites — hyperledger-fabricdocs main documentation

3、文件下载和配置

https://github.com/hyperledger/fabric/tree/v2.3.0

进入scripts,执行bootstrap.sh

在命令行输入:sudo ./bootstrap.sh

因为网络的问题,经常会下载出错,这个时候我们多执行几次,如果你没有耐心了,你可以这样做:我们对执行这个文件进行分析,无非就是下载了三个部分:

1.fabric的二进制文件

2.fabric-samples文件夹

3.fabric的镜像文件

我们可以这样:

首先,sudo ./bootstrap.sh -b  这个意思是仅仅拉去fabric的镜像文件:

执行完毕后可以发现:

然后,下载fabric-samples,

GitHub - hyperledger/fabric-samples at v2.3.0

放进scrips文件内部。

最后,下载二进制文件

https://github.com/hyperledger/fabric/releases/tag/v2.3.0

项目结构如下:

cp * /usr/local/bin/

4、测试

  • 切换到test-network目录测试网络

cd fabric-samples/test-network
  • 在目录中,运行以下命令以从任何以前的运行中删除任何容器或项目:test-network

./network.sh down

然后,您可以通过发出以下命令来启动网络

./network.sh up

生成容器

1、创建通道

./network.sh createChannel

出现以上代码,则表示成功

2、在通道上启动链码,部署链码

./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go

正常情况下是运行报错的。

链码路径,没有vendor文件夹(go语言依赖包)。

所以要 运行

go mod vendor

这个需要翻墙,也报错先执行下面代码,为go语言源换一个境内源。

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct

然后执行        go mod vendor

最后执行部署链码命令

./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go

出现以上代码,则成功。

3、添加机构1的环境变量

(test-network)目录下执行

export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/# Environment variables for Org1export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051

4、使用资产初始化分类帐

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":[]}'
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
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"]}'

如果成功,您应该看到类似于以下内容的输出:

5、添加机构2的环境变量

使机构2可以与链码交互

# Environment variables for Org2export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=localhost:9051

您现在可以查询,在上运行的资产转移(基本)链码

peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'

结果如下:

6、关闭网络

./network.sh down

博主运行代码如下,仅供参考。

hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network$ sudo su root
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker ps
CONTAINER ID   IMAGE                               COMMAND             CREATED          STATUS          PORTS                                                                                  NAMES
aadb837df673   hyperledger/fabric-tools:latest     "/bin/bash"         15 minutes ago   Up 15 minutes                                                                                          cli
c4434566b601   hyperledger/fabric-orderer:latest   "orderer"           15 minutes ago   Up 15 minutes   0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp   orderer.example.com
36ba6d8f081a   hyperledger/fabric-peer:latest      "peer node start"   15 minutes ago   Up 15 minutes   7051/tcp, 0.0.0.0:9051->9051/tcp, :::9051->9051/tcp                                    peer0.org2.example.com
88e6f142ed46   hyperledger/fabric-peer:latest      "peer node start"   15 minutes ago   Up 15 minutes   0.0.0.0:7051->7051/tcp, :::7051->7051/tcp                                              peer0.org1.example.com

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker -v
Docker version 20.10.12, build e91ed57
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker-compose -v
docker-compose version 1.25.0, build unknown
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# go version
go version go1.15.2 linux/amd64

hanlw@ubuntu:~/go/src/hyperleger$ cd fabric-2.3.0/
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0$ ls
bccsp         cmd                 config           docker-env.mk  go.sum      integration     Makefile  pkg            sampleconfig  tox.ini
bin           CODE_OF_CONDUCT.md  CONTRIBUTING.md  docs           gotools.mk  internal        msp       protoutil      scripts       vagrant
CHANGELOG.md  CODEOWNERS          core             go.mod         idemix      LICENSE         NOTICE    README.md      SECURITY.md   vendor
ci            common              discovery        gossip         images      MAINTAINERS.md  orderer   release_notes  tools
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0$ cd scripts/
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0/scripts$ cd fabric-samples/

hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples$ ls
asset-transfer-abac            asset-transfer-sbe                CHANGELOG.md        config               LICENSE         SECURITY.md
asset-transfer-basic           asset-transfer-secured-agreement  ci                  CONTRIBUTING.md      MAINTAINERS.md  test-application
asset-transfer-events          auction                           CODE_OF_CONDUCT.md  fabcar               off_chain_data  test-network
asset-transfer-ledger-queries  bin                               CODEOWNERS          high-throughput      README.md       token-erc-20
asset-transfer-private-data    chaincode                         commercial-paper    interest_rate_swaps  scripts         token-utxo

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker images
REPOSITORY                   TAG       IMAGE ID       CREATED         SIZE
hyperledger/fabric-tools     2.3       2172e1e8ef5a   14 months ago   438MB
hyperledger/fabric-tools     2.3.0     2172e1e8ef5a   14 months ago   438MB
hyperledger/fabric-tools     latest    2172e1e8ef5a   14 months ago   438MB
hyperledger/fabric-peer      2.3       a572d898402a   14 months ago   56MB
hyperledger/fabric-peer      2.3.0     a572d898402a   14 months ago   56MB
hyperledger/fabric-peer      latest    a572d898402a   14 months ago   56MB
hyperledger/fabric-orderer   2.3       0a77c2792890   14 months ago   39.2MB
hyperledger/fabric-orderer   2.3.0     0a77c2792890   14 months ago   39.2MB
hyperledger/fabric-orderer   latest    0a77c2792890   14 months ago   39.2MB
hyperledger/fabric-ccenv     2.3       9432940881da   14 months ago   502MB
hyperledger/fabric-ccenv     2.3.0     9432940881da   14 months ago   502MB
hyperledger/fabric-ccenv     latest    9432940881da   14 months ago   502MB
hyperledger/fabric-baseos    2.3       4dbd6846872b   14 months ago   6.39MB
hyperledger/fabric-baseos    2.3.0     4dbd6846872b   14 months ago   6.39MB
hyperledger/fabric-baseos    latest    4dbd6846872b   14 months ago   6.39MB
hyperledger/fabric-ca        1.4       dbbc768aec79   15 months ago   158MB
hyperledger/fabric-ca        1.4.9     dbbc768aec79   15 months ago   158MB
hyperledger/fabric-ca        latest    dbbc768aec79   15 months ago   158MB

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# ./network.sh down
Stopping network
Removing network net_test
Removing volume net_orderer.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer0.org2.example.com
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
No containers available for deletion
No images available for deletion
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
5cc84ad355aa: Pull complete 
Digest: sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678
Status: Downloaded newer image for busybox:latest

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/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.0
DOCKER_IMAGE_VERSION=2.3.0
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/../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 "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating peer0.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com    ... done
Creating cli                    ... done

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/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'
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/../bin/configtxgen
+ configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/mychannel.block -channelID mychannel
2022-01-18 19:54:54.278 PST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2022-01-18 19:54:54.283 PST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2022-01-18 19:54:54.283 PST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216 
2022-01-18 19:54:54.283 PST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/configtx/configtx.yaml
2022-01-18 19:54:54.284 PST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2022-01-18 19:54:54.284 PST [common.tools.configtxgen] doOutputBlock -> INFO 006 Creating application channel genesis block
2022-01-18 19:54:54.284 PST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
Creating channel mychannel
Using organization 1
+ osnadmin channel join --channel-id mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:7053 --ca-file /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --client-cert /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt --client-key /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
+ res=0
Status: 201
{
    "name": "mychannel",
    "url": "/participation/v1/channels/mychannel",
    "consensusRelation": "consenter",
    "status": "active",
    "height": 1
}

Channel 'mychannel' created
Joining org1 peer to the channel...
Using organization 1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2022-01-18 19:55:00.450 PST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-18 19:55:00.470 PST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Joining org2 peer to the channel...
Using organization 2
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2022-01-18 19:55:03.535 PST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-18 19:55:03.562 PST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Setting anchor peer for org1...
Using organization 1
Fetching channel config for channel mychannel
Using organization 1
Fetching the most recent configuration block for the channel
+ peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2022-01-19 03:55:03.750 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:03.753 UTC [cli.common] readBlock -> INFO 002 Received block: 0
2022-01-19 03:55:03.753 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 0
2022-01-19 03:55:03.755 UTC [cli.common] readBlock -> INFO 004 Received block: 0
Decoding config block to JSON and isolating config to Org1MSPconfig.json
+ configtxlator proto_decode --input config_block.pb --type common.Block
+ jq '.data.data[0].payload.data.config'
Generating anchor peer update transaction for Org1 on channel mychannel
+ jq '.channel_group.groups.Application.groups.Org1MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org1.example.com","port": 7051}]},"version": "0"}}' Org1MSPconfig.json
+ configtxlator proto_encode --input Org1MSPconfig.json --type common.Config
+ configtxlator proto_encode --input Org1MSPmodified_config.json --type common.Config
+ configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
+ configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
+ jq .
++ cat config_update.json
+ echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":{' '"channel_id":' '"mychannel",' '"isolated_data":' '{},' '"read_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org1MSP":' '{' '"groups":' '{},' '"mod_policy":' '"",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '},' '"write_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org1MSP":' '{' '"groups":' '{},' '"mod_policy":' '"Admins",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"AnchorPeers":' '{' '"mod_policy":' '"Admins",' '"value":' '{' '"anchor_peers":' '[' '{' '"host":' '"peer0.org1.example.com",' '"port":' 7051 '}' ']' '},' '"version":' '"0"' '},' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"1"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '}}}}'
+ configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
2022-01-19 03:55:04.017 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:04.042 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org1MSP' on channel 'mychannel'
Setting anchor peer for org2...
Using organization 2
Fetching channel config for channel mychannel
Using organization 2
Fetching the most recent configuration block for the channel
+ peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2022-01-19 03:55:04.243 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:04.246 UTC [cli.common] readBlock -> INFO 002 Received block: 1
2022-01-19 03:55:04.247 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 1
2022-01-19 03:55:04.249 UTC [cli.common] readBlock -> INFO 004 Received block: 1
Decoding config block to JSON and isolating config to Org2MSPconfig.json
+ configtxlator proto_decode --input config_block.pb --type common.Block
+ jq '.data.data[0].payload.data.config'
+ jq '.channel_group.groups.Application.groups.Org2MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org2.example.com","port": 9051}]},"version": "0"}}' Org2MSPconfig.json
Generating anchor peer update transaction for Org2 on channel mychannel
+ configtxlator proto_encode --input Org2MSPconfig.json --type common.Config
+ configtxlator proto_encode --input Org2MSPmodified_config.json --type common.Config
+ configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
+ configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
+ jq .
++ cat config_update.json
+ echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":{' '"channel_id":' '"mychannel",' '"isolated_data":' '{},' '"read_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org2MSP":' '{' '"groups":' '{},' '"mod_policy":' '"",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '},' '"write_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org2MSP":' '{' '"groups":' '{},' '"mod_policy":' '"Admins",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"AnchorPeers":' '{' '"mod_policy":' '"Admins",' '"value":' '{' '"anchor_peers":' '[' '{' '"host":' '"peer0.org2.example.com",' '"port":' 9051 '}' ']' '},' '"version":' '"0"' '},' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"1"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '}}}}'
+ configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
2022-01-19 03:55:04.507 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:04.524 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org2MSP' on channel 'mychannel'
Channel 'mychannel' joined

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: basic
- CC_SRC_PATH: ../asset-transfer-basic/chaincode-go
- CC_SRC_LANGUAGE: go
- CC_VERSION: 1.0
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: NA
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Vendoring Go dependencies at ../asset-transfer-basic/chaincode-go
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/asset-transfer-basic/chaincode-go /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network
go: github.com/golang/protobuf@v1.3.2: Get "https://proxy.golang.org/github.com/golang/protobuf/@v/v1.3.2.mod": dial tcp 142.251.43.17:443: i/o timeout
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network
Finished vendoring Go dependencies
+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-go --lang golang --label basic_1.0
+ res=0
Chaincode is packaged
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install basic.tar.gz
+ res=0
2022-01-18 19:56:23.181 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad\022\tbasic_1.0" > 
2022-01-18 19:56:23.181 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad
Chaincode is installed on peer0.org1
Install chaincode on peer0.org2...
Using organization 2
+ peer lifecycle chaincode install basic.tar.gz
+ res=0
2022-01-18 19:56:33.076 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad\022\tbasic_1.0" > 
2022-01-18 19:56:33.076 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad
Chaincode is installed on peer0.org2
Using organization 1
+ peer lifecycle chaincode queryinstalled
+ res=0
Installed chaincodes on peer:
Package ID: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad, Label: basic_1.0
Query installed successful on peer0.org1 on channel
Using organization 1
+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --version 1.0 --package-id basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad --sequence 1
+ res=0
2022-01-18 19:56:35.256 PST [chaincodeCmd] ClientWait -> INFO 001 txid [3b9fbc1703895142f114bf999c9eea025e72998634562b5f48c67408ec3df4c1] committed with status (VALID) at localhost:7051
Chaincode definition approved on peer0.org1 on channel 'mychannel'
Using organization 1
Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
    "approvals": {
        "Org1MSP": true,
        "Org2MSP": false
    }
}
Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
    "approvals": {
        "Org1MSP": true,
        "Org2MSP": false
    }
}
Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 2
+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --version 1.0 --package-id basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad --sequence 1
+ res=0
2022-01-18 19:56:43.556 PST [chaincodeCmd] ClientWait -> INFO 001 txid [3fb5559603c11bd5b2564c4275ece248518bef1cefba1f9b72a11954f0788652] committed with status (VALID) at localhost:9051
Chaincode definition approved on peer0.org2 on channel 'mychannel'
Using organization 1
Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
    "approvals": {
        "Org1MSP": true,
        "Org2MSP": true
    }
}
Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
    "approvals": {
        "Org1MSP": true,
        "Org2MSP": true
    }
}
Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 1
Using organization 2
+ peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --peerAddresses localhost:7051 --tlsRootCertFiles /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1.0 --sequence 1
+ res=0
2022-01-18 19:56:51.992 PST [chaincodeCmd] ClientWait -> INFO 001 txid [1ba67fae47f0174aa971a7ee43bd7af0bbe1cd16f55ef8daee5722230d4cf518] committed with status (VALID) at localhost:7051
2022-01-18 19:56:52.015 PST [chaincodeCmd] ClientWait -> INFO 002 txid [1ba67fae47f0174aa971a7ee43bd7af0bbe1cd16f55ef8daee5722230d4cf518] committed with status (VALID) at localhost:9051
Chaincode definition committed on channel 'mychannel'
Using organization 1
Querying chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to Query committed status on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode querycommitted --channelID mychannel --name basic
+ res=0
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Querying chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to Query committed status on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode querycommitted --channelID mychannel --name basic
+ res=0
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
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

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export PATH=${PWD}/../bin:$PATH
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export FABRIC_CFG_PATH=$PWD/../config/
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ENABLED=true
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_LOCALMSPID="Org1MSP"
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_ADDRESS=localhost:7051

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/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":[]}'
2022-01-18 20:41:44.848 PST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/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}]

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/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"]}'
2022-01-18 20:45:22.523 PST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/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":"Christopher","appraisedValue":800}]

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ENABLED=true
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_LOCALMSPID="Org2MSP"
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_ADDRESS=localhost:9051

root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
{"ID":"asset6","color":"white","size":15,"owner":"Christopher","appraisedValue":800}

参考:

关于fabric中执行./bootstrap.sh之后出错的解决方案_lakersssss24的博客-CSDN博客

超级账本 hyperledger fabric v2.3 安装与测试网络_哔哩哔哩_bilibili

Hyperledger Fabric2.3 环境搭建及Fabric 测试网络使用_peimina的博客-CSDN博客

Hyperledger Fabric2.3 环境搭建及Fabric 测试网络使用相关推荐

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

    一篇博文体验Hyperledger Fabric区块链 系统环境(CentOS): [root@localhost ~]# cat /proc/version Linux version 3.10.0 ...

  2. M1芯片下Fabric测试网络环境配置

    M1芯片下Fabric测试网络环境配置 系统配置 系统:Ubuntu 20.04 LTS 内核:Arm64 硬盘大小:10GB 1.技术框架环境搭建 安装Vim sudo apt install -y ...

  3. 鸿蒙硬件HI3861开发环境搭建-串口2测试

    鸿蒙硬件HI3861开发环境搭建-串口2测试 鸿蒙硬件HI3861开发环境搭建-串口2测试 - 哔哩哔哩 鸿蒙其他教程请看https://blog.csdn.net/qq_33259323/categ ...

  4. U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection|环境搭建|人物素描 测试 简记 |

    这个代码非常强大,最近作者更新了模型 我也特别更新一篇博文 [最新同步更新教程链接 – 2021-9-3 ]-- 敬请移步 文章目录 U2-Net: Going Deeper with Nested ...

  5. 小程序-本地环境搭建-线上测试搭建-线上正式环境搭建

    本地环境搭建 本地环境只能自己测试 小程序的url设置为localhost.127.0.0.1.或者xxx.xxx.com/api (需要配置hosts)都可以,本地的地址,不需要在小程序后台配置,l ...

  6. 【区块链】使用 Fabric 测试网络

    首先,我们要回到官方文档 https://hyperledger-fabric.readthedocs.io/en/release-2.4/test_network.html 运行 fabric 测试 ...

  7. Linux环境配置编译orange,orangepi zero2编译环境搭建及传感器测试

    一.编译环境搭建及版本镜像编译 我这里使用的是官方手册上提供的linux SDK,包括uboot.linux内核及根文件系统均是orangePI官方的代码包,但在使用的一开始,我就遇到一个让人比较郁闷 ...

  8. fabric测试网络启动警告解决:Local fabric binaries and docker images are out of sync. This may cause problems.

    警告信息: Local fabric binaries and docker images are out of sync. This may cause problems. Local fabric ...

  9. 区块链——Hyperledger Fabric2.2单点搭建网络

    文章目录 一.搭建基础环境 二.生成证书文件 1.准备证书配置文件模板 2.修改模板 3.生成证书文件 三.生成通道文件 1.编写创世快文件 2.生成创世块文件和通道文件 三.配置各个节点 1.编写d ...

最新文章

  1. Can not find the tag library descriptor for http://www.springframework.org/tags/form 解决方法
  2. c++ char数组和char*
  3. VTK:Filtering之LandmarkTransform
  4. 解决 Beyond Compare 3 许可证密钥被撤销
  5. Byte[]、Image、Bitmap 之间的相互转换
  6. refresh-刷新
  7. 使用Angular4手把手构建符合企业实际的项目管理系统----【npm】工具的使用
  8. hdu 4638 Group
  9. 基于Spring MVC的Excel文件上传
  10. MATLAB for循环
  11. Linux操作系统分区格式Ext2,Ext3,Ext4的区别
  12. MATLAB【工具箱下载】汇总
  13. 计算机无法搜索照片,电脑上照片查看器无法打开照片
  14. 【乐理入门】——音符与五线谱(1)
  15. 中国成网络攻击最大受害国之一
  16. SwiftUI学习笔记[path绘制]
  17. Linux系统下C语言实现遍历该目录下所有文件
  18. 程序员公众号编辑神器-mdnice
  19. 夜天之书 #49 开源软件的技术写作
  20. SSM框架实例——在线考试系统

热门文章

  1. Mac系统 Terminal终端功能使用方法
  2. 解决类别不平衡问题的方法综述
  3. android 揭示动画_揭示自动驾驶汽车第4级和第5级的真实含义
  4. 贝叶斯分类器详解 从零开始 从理论到实践
  5. 婚恋网站有风险,网上交友须谨慎
  6. 极验验证(滑动验证)的使用
  7. 阿里云GanosBase升级,发布首个云孪生时空数据库
  8. Java设计安全的登录接口
  9. 10个python接私活的平台,整整10个,总有适合你的,你有技术就有钱
  10. 项目如何进行压力测试?