Commit 4e956118 authored by Anastasios Kalogeropoulos's avatar Anastasios Kalogeropoulos
Browse files

readme deleted from chaincode dir

parent 9eeacbfd
# Deploy chaincode on the Test Network
Before you proceed, make sure that you have installed the [prerequisites](https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html#).
Also, make sure that you have [Installed Fabric and Fabric samples](https://hyperledger-fabric.readthedocs.io/en/latest/install.html).
Download the `evidentia-chaincode` project and **copy** it under the `fabric-samples` directory. The chaincode for Evidentia is implemented in [Go](https://golang.org/), so make sure that you have configured your machine properly.
## Package chaincode with dependencies
To install the chaincode dependencies, run the following commands inside the `evidentia` directory:
*NOTE: The chaincode dependencies are already installed. Run the following two steps in case you want to re-install them.*
1. `go mod init evidentia`
2. `GO111MODULE=on go mod vendor`
The first command will create a file named `go.mod` which should look like below:
```
module evidentia
go 1.15
require github.com/hyperledger/fabric-contract-api-go v1.1.1
```
The following steps provide a summary of how to start the `test-network`, included in the `fabric-samples` directory and deploy the *evidentia* chaincode on the channel. More details can be found [here](https://hyperledger-fabric.readthedocs.io/en/latest/deploy_chaincode.html#package-the-smart-contract).
Navigate to the `test-network` directory.
Start the network using Certificate Authorities:
```
./network.sh up -ca
```
Create a channel with default name `mychannel`:
```
./network.sh createChannel
```
Add binaries to CLI Path:
```bash
export PATH=${PWD}/../bin:$PATH
```
Configure `FABRIC_CFG_PATH`:
```bash
export FABRIC_CFG_PATH=$PWD/../config/
```
Create the chaincode package:
```bash
peer lifecycle chaincode package evidentia.tar.gz --path ../evidentia/ --lang golang --label evidentia_1.0
```
Install the chaincode package as **Org1**:
```bash
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
peer lifecycle chaincode install evidentia.tar.gz
```
Install the chaincode package as **Org2**:
```bash
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_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 lifecycle chaincode install evidentia.tar.gz
```
Approve chaincode definition for **Org2**:
```bash
peer lifecycle chaincode queryinstalled
## DO NOT COPY - replace with package id from the previous command
export CC_PACKAGE_ID=evidentia_1.0:3e0024708a8a678f654252ee6149e860067bb8f434df9899b34778663f70bff0
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name evidentia --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
```
Approve chaincode definition for **Org1**:
```bash
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_ADDRESS=localhost:7051
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name evidentia --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
```
Commit chaincode on channel:
```bash
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name evidentia --version 1.0 --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --output json
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name evidentia --version 1.0 --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --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"
peer lifecycle chaincode querycommitted --channelID mychannel --name evidentia --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
```
Invoke chaincode and test that is working:
```bash
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 evidentia --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":"AddEvidentiaQuery","Args":["test", "testService", "[testParam1, testParam2, testParam3]"]}'
```
Read the previous entry and verify that you receive the correct data:
```bash
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 evidentia --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":"ReadEvidentiaQuery","Args":["test_testService"]}'
```
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment