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.
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
- Partner uses a fab proxy for their account to access the blockchain network. The initial partner deploys the smart contract to the blockchain network.
- Partner accesses the web application through their proxy to register on the network and view all transactions.
- Member uses a fab proxy for their account to access the blockchain network.
- 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.
- The web application uses the Ethereum web3.js library to execute the smart contract.
- The smart contract executions are updated on the network with the EVM chaincode installed on the peers.
Find the detailed instructions in the README. These steps show you how to:
- Deploy Hyperledger Fabric locally with EVM chaincode
- Set up Fab3
- Deploy the smart contract
- Set up a second Fab3
- Run the web application