1. 程式人生 > >Create a blockchain app for loyalty points with Hyperledger Fabric Ethereum Virtual Machine

Create a blockchain app for loyalty points with Hyperledger Fabric Ethereum Virtual Machine

Summary

Hyperledger Fabric provides a blockchain network with a modular architecture and consensus protocols that do not require a native cryptocurrency. Ethereum offers a structured and innovative option for writing smart contracts for decentralized applications, and then interacting with those smart contracts through libraries. This code pattern illustrates how Ethereum tools — like Solidity for writing smart contract and web3.js library for interacting with smart contracts — can be used in a blockchain application with a Hyperledger Fabric network. The pattern provides steps for deploying Fabric locally with Ethereum Virtual Machine (EVM) and creating a proxy for interacting with the smart contract through a Node.js web application.

Description

This code pattern illustrates a Hyperledger Fabric EVM that allows developers to create a blockchain application with EVM smart contract languages such as Solidity. This smart contract is deployed onto the EVM chaincode running on the Fabric peers. This pattern shows how a user, such as a member or partner for our loyalty points use case, can interact with the smart contract through Fab3, a proxy to the fabric network. Fab3 allows for using the

Ethereum web3.js library to interact with the EVM in the Fabric network.

This code pattern is for developers who want to create blockchain applications with Hyperledger Fabric EVM incorporating a Solidity smart contract. When you have completed the pattern, you will understand how to:

  • Deploy an instance of Hyperledger Fabric locally with the EVM chaincode
  • Start a Fab3 instance to interact with the Fabric network
  • Interact with the Solidity smart contract using the web3 library
  • Build a Node.js blockchain web application with the web3 library

Flow

flow

  1. Partner uses a fab proxy for their account to access the blockchain network. The initial partner deploys the smart contract to the blockchain network.
  2. Partner accesses the web application through their proxy to register on the network and view all transactions.
  3. Member uses a fab proxy for their account to access the blockchain network.
  4. Member accesses the web application through their proxy to register on the network, perform transactions to earn or redeem points from the partners on the network, and view all transactions.
  5. The web application uses the Ethereum web3.js library to execute the smart contract.
  6. The smart contract executions are updated on the network with the EVM chaincode installed on the peers.

Instructions

Find the detailed instructions in the README. These steps show you how to:

  1. Deploy Hyperledger Fabric locally with EVM chaincode
  2. Set up Fab3
  3. Deploy the smart contract
  4. Set up a second Fab3
  5. Run the web application