Build Your First Blockchain Network: A Step-by-Step Guide

Mar 23, 2022 | Blockchain

Welcome to the thrilling journey of establishing your very first Blockchain application! In this guide, we will illuminate the process of creating a Hyperledger Composer Business Network Archive (BNA) file specifically for the commodity trading sector. This project is designed for novices, ensuring that even beginner developers can navigate through the creation and deployment phases seamlessly.

1. Understanding the Blockchain Network

Before diving headfirst into building a network, let’s take a moment to understand the architecture we will be working with. Hyperledger Fabric serves as a robust foundation for developing modular applications with components like consensus and membership services, making it easy to customize.

2. Prerequisites

  • Ensure you have the following installed:
    • Docker – version 1.13 or higher
    • Docker Compose – version 1.8 or higher
    • NPM – version 5.6.0 or higher
    • nvm – version 8.11.3
    • Node.js – version 8.11.3 (ensure not in SUDO mode)
    • Git client – version 2.9.x or higher
    • Python – version 2.7.x

3. Installation Steps

Let’s break down the installation into digestible steps:

Step 1: Install Hyperledger Composer Development Tools

First, ensure you’re using the correct Node version by checking with nvm --version. If you’re not on version 8.11, switch using nvm use 8. Next, install Composer and its components:

npm install -g composer-cli@0.20.5
npm install -g generator-hyperledger-composer@0.20.5
npm install -g composer-rest-server@0.20.5
npm install -g yo@2.0.5

Step 2: Start Hyperledger Fabric

If you’ve used an older version of Hyperledger Composer, start by removing old Docker containers with:

docker kill $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi -f $(docker images -q)

Then, use the appropriate scripts from your project directory to setup your environment.

Step 3: Generate the Business Network Archive (BNA)

You will create a BNA that encapsulates your business network definition. By running the following command, you’ll generate this archive:

npm install

Your output will confirm the creation of the my-network.bna file, ready for deployment.

Step 4: Deploy Using Composer Playground

Navigate to the Composer Playground and import your new BNA file to deploy your network. Clear your browser’s local storage first if you’re revisiting the Playground.

Step 5: Local Deployment of Business Network Archive

Finally, if you prefer to deploy locally, run the commands to install your network:

cd dist
composer network install --card PeerAdmin@hlfv1 --archiveFile my-network.bna
composer network start --networkName my-network --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin@hlfv1 --file networkadmin.card
composer card import --file networkadmin.card
composer network ping --card admin@my-network

4. Troubleshooting

If you run into issues, here are some common troubleshooting tips:

  • Check your Node.js version. Composer is sensitive to the Node environment.
  • If you see errors relating to missing modules, ensure you installed all dependencies correctly.
  • Use the provided links for installations and clarifications if you encounter any problems.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

5. Conclusion

Congratulations! You’ve now successfully built and deployed your first Blockchain network using Hyperledger Composer. With this foundational knowledge, you’re ready to embark on more complex projects as your journey continues.

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.

Additional Resources

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox