Create a decentralized energy network with IBM Blockchain Platform

Get the code

Summary

This developer code pattern first demonstrates how to package your smart contracts using the IBM Blockchain Platform VS Code extension, then setting up a network on IBM Blockchain Platform. You will then deploy the decentralized smart contract package onto the network. Lastly, we generate client-side certificates so you can subsequently enroll an application identity and submit transactions on the smart contract.

Description

A key application of blockchain being explored is a decentralized energy network. The idea stems from a neighborhood where certain residents are producing energy through solar panels or other means and can sell excess energy to residents needing energy. The transactions would be based on coins in each resident’s account. As per a pre-determined contract and rate, the coins would be debited from the consumer and credited to the producer for a certain billing period. Each transaction would need to be atomic and added to a blockchain ledger for trust and verification.

The network consists of residents, banks, and utility companies. Residents can exchange coins for energy among each other. The application assumes a pre-paid system where transactions occur after the energy is consumed and the values are updated. The resident can exchange coins for Fiat money (USD) with banks on the network. The residents can also transact coins for energy with a utility company on the network.

This code pattern demonstrates how a Node.js smart contract can be packaged using the IBM Blockchain Platform VS Code extension. Using the extension, you can set up a local instance of the Hyperledger Fabric network, on which you can install and instantiate the contract. The application is set up with a Node.js server using the Fabric Node SDK to process transactions that communicate with the network.

When you have completed this code pattern, you will understand how to:

  • Package the smart contract using IBM Blockchain Platform VS Code extension
  • Set up a Hyperledger Fabric network on IBM Blockchain Platform
  • Install and instantiate smart contract package onto the IBM Blockchain Platform
  • Develop a Node.js server with the Hyperledger Fabric SDK to interact with the deployed network
  • Interact with the contract and execute transactions using the SDK

Flow

flow

  1. The Blockchain Operator clones the GitHub repo with the decentralized energy smart contract.
  2. The Blockchain Operator uses the IBM Blockchain VS Code extension to package the smart contract.
  3. The Blockchain Operator creates a IBM Blockchain Platform 2Install chaincode on the peer node.
  4. The IBM Blockchain Platform 2.0 creates a Hyperledger Fabric network onto a IBM Kubernetes Service, enabling us to install and instantiate the decentralized energy smart contract on the network.
  5. The decentralized energy web app uses the Hyperledger Fabric Node.js SDK to submit transactions to the Hyperledger Fabric network running on IBM Cloud.
  6. The residents, banks, and utility companies interact with the decentralized energy web app and all transaction details are saved onto the IBM Blockchain Platform, unbeknown to the end user.

Instructions

Ready to get started? Please see the README for detailed instructions.