How To Run Ethereum Smart Contracts on Hyperledger Fabric?

The Hyperledger Project Executive Director, Brian Behlendorf has maintained from the inception of the project that it’s just wrong to view the Hyperledger and Ethereum communities as competitive. Ethereum is a public blockchain that allows anyone to join the network, by mining or running a node. On the other hand, Hyperledger is beneficial blockchain framework that is focusing on bringing the benefits of blockchain technology to businesses in a controlled manner. Let’s take a look at some of the critical differences between the two blockchains and see how combining the two can accomplish tasks that were previously impossible.

Ethereum v/s Hyperledger Fabric

All blockchains are not created the same. Public blockchains such as Bitcoin and Ethereum are decentralized ledgers that anyone in the world can access and use for transferring digital assets. However, there is a price to pay for the decentralized processing of transactions in the form of slow transactions and a large number of wasteful computations. On the other hand, a private blockchain created using the Hyperledger Fabric gives limited access to trusted users, typically those who were involved in the creation of the private blockchain. As a result, such blockchains have much higher throughput and therefore can perform different order of magnitudes better than public blockchains.

AD-Blockchain-Council-01

The Best of Both Worlds: Hyperledger Burrow

Burrow is a permissioned smart contract machine developed by Monax which executes Ethereum Virtual Machine (EVM) smart contract code on a permissioned virtual machine such as Hyperledger. Ethereum smart contracts are typically written in Solidity or Viper and would require no modification to be deployed on the Burrow smart contract machine. Monax CEO Casey Kuhlman claims that Burrow provides a modular blockchain client such as Fabric with an intelligent contract interpreter that can handle EVM code. Burrow relies on three main components to execute the EVM smart contract code: the consensus engine, the interpreter and the application engine. Together, these components bring permissions to Ethereum Blockchain and before running any code, make sure that necessary permissions have been granted. Such a combination is useful as it can give public blockchains the security and reliability of the Ethereum public blockchain without the additional overheads.

How to Deploy EVM smart contracts on Burrow?

Before you’re ready to deploy your smart contract code on Hyperledger, there are a few prerequisites that you must get out of the way. They include signing up for IBM cloud and setting up the IBM cloud command line interface. You would also require docker and Kubectl. Once you have the basics set up, you need to access the IBM Cloud Dashboard and sign in. After that, you need to go to the IBM Container Service and create a Cluster. After the cluster is set up, you need to find its worker nodes and save their public IP address as it will be required later. You are now ready to interact with your cluster using Kubectl.

Now, deploying the EVM smart contract to the Fabric VM requires the following four steps:

  • Clone the container service repository. It can be done by running the given command in your working directory.

    $ git clone https://github.com/SaifRehman/fabric-evm-ibm-container-service.git

  • Navigate to the container service directory which contains the scripts required to deploy the EVM code.

    –  $ cd fabric-evmibm-container-service

  • Navigate to script folder.

    –  $ cd cs-offerings/scripts

  • Deploy to Fabric with an EVM plugin to the IBM Container Service.

    –  $ ./create_all.sh

This runs the Ethereum Virtual Machine on Fabric using IBM’s container service which can now be used to execute any of the smart contract code written in solidity or viper.