Create a decentralized energy network with Hyperledger Composer  

Create a blockchain app to display and interact with a network through a web interface

Last updated | By Raheel Zubairy


Wondering where blockchain might apply in your own life? Interested in energy, sustainability, or climate change? Try your hand at creating a basic blockchain app to interact with a decentralized energy network! The idea behind the app is a neighborhood where residents produce and sell excess solar-panel energy to residents who need it. This is an excellent example of how blockchain can begin to transform our world.


A great way to start experimenting with blockchain is to model a network and build a blockchain application using the Hyperledger Composer toolset. In this pattern, the application presents a decentralized energy network where neighborhood residents who are producing energy through solar panels or other means can sell excess energy to fellow residents or utility companies.

Here’s how it works: The application allows the user to create network participants with account balances who can exchange coins for energy shared. (The network also includes banks to exchange cash for coins.) Transactions can be between residents, between resident and bank, or between resident and utility company. The application updates balances for each transaction, and each transaction is added to a blockchain ledger for trust and verification.

Once you create the application, you can expand it in several ways. For example, you can add specific permissions and participant access, set up real-time transactions among participants, and even integrate with IoT to read from power meters and distribute energy.


  1. Administrator interacts with decentralized energy UI comprising Angular framework.
  2. Application processes user requests to the network through a REST API.
  3. Requests are implemented to the blockchain state database on Hyperledger Fabric v1.
  4. REST API is used to retrieve the state of the database.
  5. Angular framework gets data through GET calls to the REST API.


To get started, all you need is Docker, npm, Node, Hyperledger Fabric, and Hyperledger Composer. (See the README for version notes.)

Then follow these 7 basic steps to create the network, start the application, and run energy-sharing transactions on the network:

  1. Clone the repo

    Clone the Decentralized-Energy-Composer code locally:

    git clone
  2. Set up Hyperledger Fabric

    Kill and remove any running containers or previously created Hyperledger Fabric chaincode images:

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

    Set the Hyperledger Fabric version to v1.1:

    export FABRIC_VERSION=hlfv11

    All the scripts are in /fabric-tools. Start Fabric and create the profile:

    cd fabric-tools/ ./ ./ ./
  3. Generate the Business Network Archive (BNA)

    Generate the BNA file from the root directory:

    cd ../ npm install composer archive create -a dist/decentralized-energy-network.bna --sourceType dir --sourceName .

    The composer archive create command creates a file called decentralized-energy-network.bna in the dist folder.

  4. Deploy to Fabric

    Deploy the BNA file to Hyperledger Fabric:

    First, install the composer runtime:

    cd dist/ composer network install --card PeerAdmin@hlfv1 --businessNetworkName decentralized-energy-network

    Deploy the business network:

    composer network start --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile decentralized-energy-network.bna --file networkadmin.card

    Import the network administrator identity as a usable business network card:

    composer card import --file networkadmin.card

    Check that the business network has been deployed successfully, run the following command to ping the network:

    composer network ping --card admin@decentralized-energy-network
  5. Run the application

    Go into the angular-app folder and install the dependency:

    cd ../angular-app/ npm install

    To start the application:

    npm start

    The application should now be running at: http://localhost:4200

    The REST server to communicate with network is available here: http://localhost:3000/explorer/

  6. Create participants

    Once the application opens, create participants and fill in dummy data. Create Residents, Banks, and Utility Companies.

  7. Execute transactions

    Execute transactions manually between Residents, Resident and Bank, and Resident and Utility Company. After executing transactions, ensure the participants’ account values are updated.

    At the end of your session, stop Fabric:

    cd ~/fabric-tools ./ ./

Related Blogs

blockchain4business bootcamp in Munich

Blockchain4Business was a bootcamp which took place from 15th – 18th July 2018 in Munich, Germany. This was the third event of its kind, designed for individuals and companies interested in hands-on learning and hacking of Hyperledger Fabric applications. This four-day event was organized by the Frankfurt School Blockchain Center,, the Johannes Gutenberg University...

Continue reading blockchain4business bootcamp in Munich

Two “edgy” AI TensorFlow models for you!

The global Call for Code is well underway, we want to share some visual recognition models which could help you. These AI models can operate on the edge, which could be particularly useful for this years’ theme: disaster preparedness. How could visual recognition help in relief work? From satellite and drone imagery analysis, to classifying...

Continue reading Two “edgy” AI TensorFlow models for you!

Leveraging the power of AI at Unite Berlin

Last week, from June 19 – 21, we were at Unity’s premiere in Berlin: Unite 2018. This conference brought together Unity’s video game and development community. Unity touches 770 million gamers all over the world and is the market leader for consumer AR and VR use cases and is also rapidly emerging as the market...

Continue reading Leveraging the power of AI at Unite Berlin

Related Links

IBM Blockchain

Learn about blockchain basics, explore use cases, find tutorials, sample code, and blogs, and check out IBM solutions.