Prerequisite: The first-samples has been downloaded, and fabric1.0 has been downloaded.
1: Enter the First-samples directory
Execute Cryptogen generate--CONFIG=./CRYPTO-CONFIG.YAML, generate a certificate for two org
2: first, we need to set an environment variable to specify where Configtxgen should look for the Configtx.yaml configuration file :
Implementation: Export Fabric_cfg_path= $PWD
3: Then we will call the Configtxgen tool that will create the order source code block
Configtxgen-profile Twoorgsorderergenesis-outputblock./channel-artifacts/genesis.block
(Create the Genesis block Genesis.block below the CLI directory and save the chunk to the local channel-artifacts folder)
4: Next, we need to create a channel transaction artifact
Export Channel_name=mychannel
Configtxgen-profile twoorgschannel-outputcreatechanneltx./channel-artifacts/channel.tx-channelid $CHANNEL _name
(Generate channel configuration block CHANNEL.TX)
5: Next, we will define the anchor peers for ORG1 and ORG2 on the channel being built.
Configtxgen-profile twoorgschannel-outputanchorpeersupdate./channel-artifacts/org1mspanchors.tx-channelid $ Channel_name-asorg Org1msp
Configtxgen-profile twoorgschannel-outputanchorpeersupdate./channel-artifacts/org2mspanchors.tx-channelid $ Channel_name-asorg Org2msp
(generates two anchor peer anchor peers)
6: The preparation work is done, you can start the network. Because we need to use COUCHDB .
So execute: channel_name= $CHANNEL _name timeout=1000 docker-compose-f docker-compose-cli.yaml-f Docker-compose-couch.yaml Up-d
7: Setting the Manual environment: Peer0
# Environment Variables for PEER0
core_peer_mspconfigpath=/opt/gopath/src/github.com/hyperledger/fabric/peer/ Crypto/peerorganizations/org1.example.com/users/admin@org1.example.com/msp
core_peer_address= peer0.org1.example.com:7051
core_peer_localmspid= "Org1msp"
core_peer_tls_rootcert_file=/opt/gopath/src /github.com/hyperledger/fabric/peer/crypto/peerorganizations/org1.example.com/peers/peer0.org1.example.com/tls /ca.crt
8: You can now enter the CLI container for specific operations:
Docker exec-it CLI Bash
9:export Channel_name=mychannel
Create Channel: Peer Channel Create-o orderer.example.com:7050-c $CHANNEL _name-f/channel-artifacts/channel.tx--tls $CORE _peer _tls_enabled--cafile/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererorganizations/example.com /orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
10: Adding nodes to the channel
The default is: Peer0org1. Execution: Peer Channel Join-b Mychannel.block
11: Add chain code to the node
Peer Chaincode install-n marbles-v 1.0-p github.com/hyperledger/fabric/examples/chaincode/go/marbles02
12: Instantiate the chain code:
Peer Chaincode instantiate-o orderer.example.com:7050--tls $CORE _peer_tls_enabled--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 $CHANNEL _name-n marbles-v 1.0-c ' {"Args": ["Init"]} '-P "OR (' Org0msp.member ', ' Org1msp.member ') "
13: The initialization of the chain code:
1:peer Chaincode invoke-o orderer.example.com:7050--tls $CORE _peer_tls_enabled--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 $CHANNEL _name-n marbles-c ' {"Args": ["initmarble", "Marble1", "Blue", "35", " Tom "]} '
2:peer Chaincode invoke-o orderer.example.com:7050--tls $CORE _peer_tls_enabled--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 $CHANNEL _name-n marbles-c ' {"Args": ["initmarble", "Marble2", "Red", "50", " Tom "]} '
3:peer Chaincode invoke-o orderer.example.com:7050--tls $CORE _peer_tls_enabled--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 $CHANNEL _name-n marbles-c ' {"Args": ["initmarble", "Marble3", "Blue", "70", " Tom "]} '
14: Conduct trading operations:
1:peer Chaincode invoke-o orderer.example.com:7050--tls $CORE _peer_tls_enabled--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 $CHANNEL _name-n marbles-c ' {"Args": ["transfermarble", "Marble2", "Jerry"]} '
2: peer Chaincode invoke-o orderer.example.com:7050--tls $CORE _peer_tls_enabled--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 $CHANNEL _name-n marbles-c ' {"Args": ["Transfermarblesbasedoncolor", "Blue", "Jerry"]} '
16: To Be Continued ...