Ethereum smart contracts

How to Set up Hyperledger Smart Contracts for Ethereum

Estimated read time: 9 minutes

Planning on using Hyperledger Fabric to set up Ethereum smart contractsThis is an important topic that we will cover here.

In this article

  1. Hyperledger Fabric Smart Contracts for Ethereum
  2. Fabric embraces “Ethereum Virtual Machine” (EVM)
  3. How to set up a Fabric Smart Contract using Ethereum?
  4. Frequently Asked Questions on Hyperledger smart contracts

According to a report, the global smart contract market is expected to reach $2.5 billion by 2032 — up from $192.7 million back in 2022. The same report states that the Ethereum segment accounted for nearly one-third of the global smart contract market revenue in 2022 and is projected to retain its highest share during the forecast period (2022-2032).

Hyperledger Fabric Smart Contracts for Ethereum

An infographic illustrating how Smart Contracts work

So long, Fabric allowed developers to code chaincodes, but not Ethereum smart contracts. An Ethereum smart contract is important in the history of blockchain technology. This is due to the following reasons:

  • Bitcoin has always been a “Peer-to-Peer”(P2P) network for transferring Bitcoin without the intervention of 3rd parties like banks. It didn’t cater to any other use case.
  • Ethereum introduced smart contracts, i.e., open-source code with “If-Then-Else” statements that transferred cryptographic assets based on fulfillment of predetermined conditions.
  • This smart contract executes autonomously, and they are stored transparently in the Ethereum blockchain.
  • No one can tamper with them after deployment. I have explained this in “How to Deploy Smart Contract on Ethereum?”.
  • Smart contract execution is irreversible.
  • These transformative characteristics of a smart contract enabled entrepreneurs and developers to build decentralized business models using the Ethereum blockchain.
  • This significantly improved the adoption of blockchain technology, as the wave of ICOs has shown.

You see, blockchain skills are niche. This is true for Ethereum as well as for key enterprise blockchain like Fabric. However, Ethereum enjoys considerable mindshare due to the popularity of smart contracts written in Solidity. There is also Vyper, a relatively new language to write Ethereum smart contracts.

A perceived disadvantage of Fabric was that it didn’t offer the ability to write a simple smart contract on ethereum. That’s changing now, as Fabric is now allowing developers to do this.

Fabric embraces “Ethereum Virtual Machine” (EVM)

To enable the development of Ethereum smart contracts on Fabric, the Fabric project has incorporated the following:

Component #1: “Ethereum Virtual Machine” (EVM)

Ethereum is a collection of protocols that allow developers to create “Decentralized Applications” (DApps). “Ethereum Virtual Machine” (EVM) assumes the central position in this collection of protocols. This executes the code the developers write as part of their DApps.

banner-img

Get a complimentary discovery call and a free ballpark estimate for your project

Trusted by 100x of startups and companies like

Read more about EVM in “What is EVM?”.

Fabric used to have Hyperledger Burrow. It was a project under the Hyperledger community that provided a blockchain client. It also provided a smart contractor interpreter, modeled after EVM. You can read more about Hyperledger Burrow.

Component #2: Accounts

Ethereum features the following types of accounts:

  • “Externally Owned Accounts” (EOAs): On the Ethereum blockchain network, these are the user accounts. These represent the public address of users and their Ether (ETH) balance. Users control these with their private keys. Read more about EOAs in “What Are Externally Owned Accounts (EOAs) in Ethereum?”.
  • “Contract Accounts” (CAs): These are controlled by smart contracts. These contain the runtime EVM bytecode for a contract.

At the time of writing, there is no known plan of any Hyperledger Fabric coin. Therefore, Fabric will generate EOAs on the fly. Fabric will store CAs on the chain.

Component #3: Ethereum client

Ethereum developers use the “TestRPC” Ethereum client. Read more about it in their GitHub repository. Fabric EVM implementation uses the JSON RPC API partially.

Ethereum developers also use “Web3.js”, i.e., a tool to communicate with the Ethereum blockchain. The Fabric EVM implementation uses Fab3, which allows the partial implementation of the JSON RPC API. You can read more about Fab3 in this tutorial on GitHub.

Component #4: “Gas”

“Gas” is a kind of fee. Users need to pay enough gas to execute any operation on the Ethereum blockchain network. Smart contract transactions that require more computation requires higher gas than the ones with less computing requirements.

A smart contract transaction won’t execute if users provide insufficient gas. Ethereum users pay for gas with Ether (ETH), i.e., the native cryptocurrency of the platform.

Read this Ethereum stack exchange Q&A thread for more information. In case the Fabric EVM implementation, a large amount of gas is hardcoded.

How to set up a Fabric Smart Contract using Ethereum?

I will now explain the process to set up a basic smart contract on Fabric, as follows:

Hire expert developers for your next project

62 Expert dev teams,
1,200 top developers
350+ Businesses trusted
us since 2016

Step #1: Install the required tools

You need to install the following tools:

  • cURL: It’s a tool for transferring files from or to a server. Install it following the instructions here.
  • Docker: Developers increasingly use “Docker” to create, deploy, and run applications using containers. Docker helps programmers to create a complete package for an app, including libraries and dependencies. They can then deploy it on their choice of platform. Read the installation instructions on the Docker website. The installation process includes “Docker Compose”, i.e., a tool to define and run multi-container apps.
  • Programming languages: You are setting up Ethereum smart contracts on Fabric to use in your application. Developers typically write apps on Fabric using “Go” or Node.js. You need to install either of them. Check the Go programming language website for installation instructions. Fabric currently supports Node.js v8.9, and you can install it using their instructions.

Read more in this Fabric prerequisites web page.

Step #2: Install binaries, samples, and Docker images

Fabric documentation already includes sample applications, and developers can use these to expedite their project. Fabric also provides binaries and Docker images for these. You will find these useful to fast-track your projects. Read “Install Samples, Binaries and Docker Images” for more details.

Step #3: Install Fabric EVM chaincode

Now, you need to install the Fabric EVM chaincode. This will enable you to interact with the Ethereum smart contracts you will write, using Fabric. Follow the detailed instructions in this guide.

Step #4: Use “Remix” IDE to write Solidity smart contracts

Remix is a web-based “Integrated Development Environment” (IDE) for Ethereum smart contract development. You don’t need to install anything, just start writing Solidity smart contracts on Remix.

Step #5: Initial configuration of Fabric EVM chaincode

From this point onwards, I will use a guide that Rahul Bairathi, a Fabric expert has written. The article explains how to code Ethereum smart contracts using Fabric. You can read it in “Solidity smart contract on Hyperledger Fabric”. I will refer to it as a “reference article”.

After you have cloned the sample projects from GitHub as I have mentioned above, you need to do the following configurations:

  • Navigate to the “first-network” folder, and modify the Docker compose “Command Line Interface” (CLI) file. This is to map the folder where you have stored the code you had cloned from GitHub.
  • Start the network.
  • Navigate to the CLI Docker container and install the EVM chaincode.
  • Instantiate the EVM chaincode.

Follow the commands in the “reference article”.

Step #6: Write Solidity smart contracts

The next step involves writing Solidity smart contracts using the Remix IDE. If your team guidance, they can get check out this Remix documentation.

Step #7: Compile and deploy smart contracts

You need to take the following steps:

Hire expert developers for your next project

Trusted by
  • Compile the smart contract on Remix.
  • Copy the Bytecode. You need it to deploy the smart contract. Read more about it in this Ethereum stack exchange Q&A thread.
  • Paste the bytecode in any text editor. This will be in JSON format.
  • Deploy the smart contract using the “peer chaincode invoke” process. Your team can find the syntax of this command in this Fabric documentation page.

Read the “reference article” for more details.

Planning to build blockchain solutions using Fabric and Ethereum smart contracts?

Fabric and Ethereum have significant documentation. However, these are niche skills. A smart contract defines different business objects and logics. Developing smart contracts and other blockchain solutions using Ethereum on Fabric is a complex project. Consider engaging a reputed software development partner.

Read our guide “How to find the best software development company?” before you select a partner for your smart contract project.

If you, as a CEO or CTO, are still finding the right blockchain developers to develop fabric smart contracts for your business processes, DevTeam.Space can help you. We have a community of expert software developers, well-versed in the latest blockchain technology.

Leave us your initial smart contract development requirements via this quick form and one of our technical managers will get back to you at the earliest and assit you in team building, product development, management etc.

Frequently Asked Questions on Hyperledger smart contracts

1. How to set up Ethereum smart contracts on Hyperledger Fabric?

You need to do the following to set up Ethereum smart contracts on Hyperledger Fabric:
Install the Hyperledger Fabric framework on a “Blockchain-as-a-Service” (BaaS) platform like AWS.
Install tools like Docker, cURL. Install either Golang or Node.js.
Install binaries, sample chaincodes (smart contracts on Hyperledger Fabric), Docker images, and EVM (Ethereum Virtual Machine) chaincode.
Write Solidity smart contracts using the Remix IDE and configure the Fabric EVM chaincode.
Compile, test, and deploy smart contracts on Hyperledger Fabric.

2. Can you code smart contracts on the Hyperledger Fabric network? 

Hyperledger Fabric supports smart contracts. The Hyperledger Fabric developer community uses the term “chaincodes” to denote smart contracts.

3. Can you code Ethereum smart contracts on Hyperledger Fabric?

Starting Q4-2018, Hyperledger Fabric supports Ethereum smart contracts. Developers can write smart contract business logic in Solidity or Vyper.


Alexey

Alexey Semeney

Founder of DevTeam.Space

gsma fi band

Hire Alexey and His Team To Build a Great Product

Alexey is the founder of DevTeam.Space. He is award nominee among TOP 26 mentors of FI's 'Global Startup Mentor Awards'.

Alexey is Expert Startup Review Panel member and advices the oldest angel investment group in Silicon Valley on products investment deals.

Hire Expert Developers

Some of our projects

NewWave AI

Academic

Papers

United States

All backend All frontend Design WordPress

A website to publish AI research papers with members-only access and a newsletter.

Details
Islandbargains

Shipping

Enterprise

FL, United States

Android iOS Java Mobile PHP Web Website

A complete rebuild and further extension of our client's web and mobile shipping system that serves 28 countries.

Details
Fun And Function

Mobile Web

E-commerce

Pennsylvania, United States

All frontend Design PHP

A mobile website update for the e-commerce marketplace to support mobile traffic growth. 

Details

Read about DevTeam.Space:

Forbes

New Internet Unicorns Will Be Built Remotely

Huffpost

DevTeam.Space’s goal is to be the most well-organized solution for outsourcing

Inc

The Tricks To Hiring and Managing a Virtual Work Force

Business Insider

DevTeam.Space Explains How to Structure Remote Team Management

With love from Florida 🌴

Tell Us About Your Challenge & Get a Free Strategy Session

Hire Expert Developers
banner-img
Hire expert developers with DevTeam.Space to build and scale your software products

Hundreds of startups and companies like Samsung, Airbus, NEC, and Disney rely on us to build great software products. We can help you, too — 99% project success rate since 2016.