Install Golang
curl -O https://dl.google.com/go/go1.18.3.linux-amd64.tar.gz
tar xvf go1.18.3.linux-amd64.tar.gz
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Now, you have to open and edit you **bashrc **file. In most cases, the bashrc is a hidden file that lives in
your home directory.
nano ~/.bashrc
Add following two lines, at the end of the file:
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Create new directory where you will install Hyperledger Fabric
mkdir fabric-network
Install Hyperledger Fabric
To download a specific release, pass a version identifier for Fabric and Fabric CA Docker images. The
command below demonstrates how to download the latest production releases - Fabric v2.4.4 and Fabric
CA v1.5.3
curl -sSL https://bit.ly/2ysbOFE | bash -s -- <fabric_version> <fabric-ca_version>
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.4.4 1.5.3
Download the latest release of Fabric samples, docker images, and binaries.
curl -sSL https://bit.ly/2ysbOFE | bash -s
Now you have installed Hyperledger Fabric with all dependencies.
Deploy chaincode on peers and channel
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-typescript -ccl typescript
Interacting with the network
Set the path for peer binary and config for core.yaml
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
Set the environment variables to operate Peer as Org1
export 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
Command to initialize the ledger with assets
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":[]}'
Query the ledger
Run the following command to get the list of assets that were added to your channel ledger:
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
The output of the command will display the result of the "GetAllAssets" function query, showing the
assets retrieved from the ledger.