This documentation outlines the steps required to set up and run the Supply Chain Smart Contract application developed in Go. This application utilizes Hyperledger Fabric's Contract API to manage products in a supply chain scenario.
Before proceeding with the setup, ensure that you have the following prerequisites installed on your system:
- Go (version 1.21.4 or later)
- Git (for cloning the repository)
After cloning the repository, navigate to the project directory:
cd CSE598-EBA-Project2The project requires several Go modules as dependencies. Install them by running:
go mod tidyThis command will download and install the necessary dependencies specified in the go.mod file.
To ensure that all dependencies are available for the Hyperledger Fabric chaincode, use the go mod vendor command:
go mod vendorThis command creates a vendor directory in your project, containing all the dependencies. This is necessary for Hyperledger Fabric to package the chaincode with all its dependencies.
go test -vThis command runs the test files in the directory. It will output the results of the tests, including any failures or errors.
Navigate to the Fabric samples test network directory, which is part of the Hyperledger Fabric installation:
cd path/to/fabric-samples/test-networkReplace path/to/fabric-samples with the actual path to your Fabric samples directory.
Copy the deployment script deploy_chaincode.sh from your project directory to the Fabric samples test network directory:
cp path/to/CSE598-EBA-Project2/deploy_chaincode.sh .Replace path/to/CSE598-EBA-Project2 with the actual path to your project directory.
Give execute permissions to the deployment script and run it:
Run the deployment script with the path to the Go smart contract directory as an argument, should be replaced with the actual directory path
chmod +x deploy_chaincode.sh
./deploy_chaincode.sh <path-to-code>This script will deploy your chaincode to the Hyperledger Fabric network. Make sure to copy and enter the package ID for each organization when prompted.
After successful deployment, you can interact with the smart contract using the Fabric network CLI commands mentioned in the setup document.