Make sure you've done all the Prerequisites Network Architecture - 1 Orderer
- 1 Organization
- 3 peers
- 3 couchdb for each peer
- 1 ca
- 1 cli (Optional)
Setup the Network - Set the GOPATH. You can do this by adding this line to your
/etc/environment (for a system-wide installation) or $HOME/.bashprofile : export GOPATH=/usr/local/go. Source i f you set this in the same linux sesison then, source /etc/environment (OR) source $HOME/.bashprofile - git clone of Solo Orderer Network: git clone -b SoloOrdererNetwork https://github.com/TheCognizantFoundry/Insights.git
- cd hyperledger-fabric-basic-network
Configuration: Values like DOMAIN, CHANNEL_NAME, FABRIC_VERSION, TIME_ZONE,etc ... can be modified in .env file based on your requirement. Code Block |
---|
language | applescript |
---|
theme | Emacs |
---|
title | .env |
---|
| FABRIC_VERSION=<hyperledger_fabric_version>
COMPOSE_PROJECT_NAME=<your_project_name>
DOMAIN=<your_company.com>
CHANNEL_NAME=<channelname>
CHANNEL_FILE_NAME=<channel_transaction_filename.tx>
GENESIS_FILE_NAME=<genesis_filename.block>
CHANNEL_ARTIFACTS_PATH=<folder_path_for_storing_artifacts>
CA_USER_ENROLLMENT=<admin_username_to_be_enrolled>
CA_ENROLLMENT_SECRET=<admin_password>
TIME_ZONE=<Continent/City> |
- Provide executable permissions to sh files: chmod +x *.sh
- Start network for the first time.
network.sh - Generate the crypto-material, start/stop/restart the network. ./network.sh -m download ./network.sh -m up Start for the first time: Start/Stop the Network : ./network.sh -m start./network.sh -m stopRecreate the containers without losing the data. ./network.sh -m recreateClean and Remove the Network. ./network.sh -m downVerify if all the docker containers are running docker ps- ./network.sh itself will create and join the channel for Anchor peer - peer0.
Optional Step for information: Create and Join channel in Anchor peer - peer0.org1 : Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash Create: peer channel create -o orderer.<DOMAIN>:7050 -c mychannel -f /var/hyperledger/configs/channel.tx Join: peer channel join -o orderer.<DOMAIN> -b mychannel.block - Fetch the block and join channel in other peers:
Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Fetch block: peer channel fetch 0 mychannel.block --channelID mychannel --orderer orderer.<DOMAIN>:7050Join channel: peer channel join -o orderer.<DOMAIN> -b mychannel.block - Install,Instantiate the chaincode in Anchor peer - peer0. Get into respective peer containers and use the below install command to install chaincode in other peers.
Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash Install: peer chaincode install -n insightsAuditing -p /chaincode/src/nodejs -l node -v 1.0 If your network is in dev mode (To find the mode of your network, go to docker-compose-base/docker-compose-base.yaml and search for "peer node". If the command used is "peer node start --peer-chaincodedev=true" then you are in dev mode) - Go into cli container: docker exec -it cli bash
Execute the following command to run the chaincode in dev mode (Ensure the chaincode name and peer0 port is correct) : Code Block |
---|
CORE_CHAINCODE_ID_NAME="insightsAuditing:1.0" node --inspect tool_chaincode.js --peer.address grpc://peer0.org1.<DOMAIN>:7052 |
- Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash and execute the following command:
Instantiate: peer chaincode instantiate -n insightsAuditing -v 1.0 -c '{"Args":["init"]}' -C mychannel b. If your network is in prod mode (To find the mode of your network, go to docker-compose-base/docker-compose-base.yaml and search for "peer node". If the command used is "peer node start" then you are in prod mode) Instantiate: peer chaincode instantiate -n insightsAuditing -v 1.0 -c '{"Args":["init"]}' -C mychannel 15. Get into ca container. Create user to connect from fabric sdk by using admin. Fabric sdk network connection requires the user's cert details to get connected to the fabric network. docker exec -it ca.org1.<DOMAIN> bash fabric-ca-client enroll -u http://Admin:<password>@localhost:7054 fabric-ca-client register -u "http://localhost:7054" --id.name "newusername" --id.secret "password" --id.type "client" --id.affiliation "org1.department1" fabric-ca-client enroll -u "http://newusername:password@localhost:7054" 16. Test the Chaincode. Either insert record manually or let the data gets inserted via PlatformAuditEngine. Then, query as shown below. Modify ASSET-ID with your Asset ID value. Query: peer chaincode query -n insightsAuditing -c '{"Args":["GetAssetDetails","ASSET-ID"]}' -C mychannel
|