Welcome to your guide on migrating from Hyperledger Fabric V.6 to V1! This article will demonstrate how to set up a web-based to-do list application that will help you perform basic transactions using the powerful tools of Blockchain technology.
Understanding the Application Communication Workflow
Imagine if your to-do list application works like a bustling restaurant. Users (diners) place their order (actions) to the waiter (client application), who then conveys this order to the kitchen (server application) where the chef (Hyperledger Blockchain Network) prepares the meal (transactions). If everything goes smoothly, the chef sends the order back to the waiter, who serves it to the diner.
- The user interacts with the Todos client application in the browser.
- When an action is performed, the client calls the server API.
- The server builds a proposal and sends it for execution to the blockchain peer.
- The peer communicates with the Todos chaincode container to simulate and endorse the transaction.
- Upon endorsement, it sends back the proposal to the Todos application, which then forwards it to the ordering service.
- The orderer then packages proposals into a block, broadcasting it for peer validation.
- Once confirmed, the transaction is completed and recorded on the ledger.
Prerequisites
Before diving into the implementation, ensure that you have the following ready:
- Go – most recent version
- Docker – v1.13 or higher
- Docker Compose – v1.8 or higher
- Node.js – version 6.2.0 to 6.10.0 (v7+ not supported)
- nvm – for Node version control
Steps to Implement the To-Do List Application
- Download the Docker images and get the code for Hyperledger Fabric V1 Node SDK
- Edit the configuration
- Start your network
- Use the Node SDK
- Run the To-Do List Fabric server
- Run the To-Do List Fabric client
- Using the to-do list application
1. Download the Docker images and get the code for Hyperledger Fabric V1 Node SDK
To begin, you’ll need to download the necessary Docker images. Run the following commands:
bash
chmod +x download-dockerimages.sh
./download-dockerimages.sh
Ensure Docker is running beforehand. After completion, verify the images using:
bash
docker images
2. Edit the configuration
Modify the appropriate files in the fabric-sdk-node directory:
bash
cd fabric-sdk-node/test/integration/e2e
# Edit config.json and instantiate-chaincode.js as instructed
3. Start your network
To set up your network, navigate to the testfixtures folder and run:
bash
cd fabric-sdk-node/testfixtures
docker-compose -f docker-compose-networksetup.yaml up -d
Check your running containers using:
bash
docker ps
4. Use the Node SDK
Add the required dependency to your Node SDK:
bash
npm install
npm install -g gulp
gulp ca
5. Run the To-Do List Fabric server
Navigate to the todo-list-fabric-server directory, install the modules, and then run:
bash
npm install
node server.js
6. Run the To-Do List Fabric client
Use a web server to run the client. On Mac, utilize PHP:
bash
php -S localhost:8081
7. Using the to-do list application
Access the application at http://localhost:8081. Log in using the provided accounts:
- krhoyt:abc123
- abtin:abc123
- peter:abc123
Troubleshooting
If you encounter issues along the way, here are some useful troubleshooting tips:
- If you see an error about an existing container, use this command to remove it:
bash
docker rm -f $(docker ps -aq)
bash
rm -rf tmphfc-*
rm -rf ~/.hfc-key-store
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
Congratulations! You have successfully set up a to-do list application on IBM Blockchain using Hyperledger Fabric V1. This application demonstrates how traditional business processes can be adapted using blockchain technology.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.