This guide will walk you through the steps to set up and run a Fabric application. Follow the instructions below to clone the repository, set up the network, deploy the chaincode, and run the application.
- Ensure you have the necessary dependencies installed, including Node.js, npm, Docker, and Docker Compose.
-
Navigate to the Fabric Samples Folder
cd fabric-samples
-
Clone the Repository
git clone <repository-url>
-
Change Directory to the Fabric Application
cd fabric-app
-
Folder Structure
In the
fabric-app
directory, you will find two folders:chaincode
application
-
Set Up Chaincode
Change directory to the chaincode folder:
cd chaincode
Install the necessary Node modules:
npm install
Run the following commands to set environment variables:
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt export CORE_PEER_LOCALMSPID="Org1MSP"
-
Open a New Terminal Session
In the new terminal session, navigate to the test network directory:
cd fabric-samples/test-network
-
Shut Down Any Running Network
sudo ./network.sh down
-
Create a New Channel
./network.sh up createChannel -c mychannel -ca
-
Deploy the Chaincode
./network.sh deployCC -ccn basic -ccp ../fabric-app/chaincode/ -ccl javascript
-
Return to the Previous Terminal Session
Navigate to the application folder:
cd ../application
-
Install Node Modules
npm install
-
Run the Application
node app.js
Your Fabric application should now be up and running. Follow the steps carefully, and ensure all dependencies are installed before starting the setup process. If you encounter any issues, refer to the Fabric documentation or seek help from the community.