Skip to content

Blockchain-Based-EMR-System/Blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chaincode

install fabric

first you need to install the fabric binaries and the docker images like (peer, orderer ..).

# change dir to the root and run this command
chmod +x scripts/install-fabric.sh && ./scripts/install.-fabricsh docker binary

make a test network

this script will bring up a network with two orgs (org1 and org2) each org have one peer, the arg createChannel will create a channel between org1 and org2

cd test-network/

./network.sh up createChannel

An example of how to test the chaincode

this example is using chaincode-go basic transfer asset example

deploy the chaincode

# cd to the chaincode folder and install the dependencies
GO111MODULE=on go mod vendor


# cd to test-network folder and deploy it to the channel
./network.sh deployCC -ccn test -ccp ../chaincode-go/ -ccl go

interacting with the netwrok

to use peer CLI

# point the env vars to the bin and config folders
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/

# to set peer CLI to org1 admin
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

invoke a transaction (InitLedger)

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 test --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":[]}'

quary the ledger

peer chaincode query -C mychannel -n test -c '{"Args":["GetAllAssets"]}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors