DevTeam.Space Product Development Blog

Explore our in-depth product development tutorials and new technology announcements published by our software development experts

All articles

Blockchain Software Development Using The Ethereum Network

The blockchain technology emerged a decade ago as the foundation of Bitcoin. However, large-scale development using blockchain started with the arrival of the Ethereum network. Ethereum enabled entrepreneurs and developers to build new business models. So, what should you do for blockchain software development using the Ethereum network? Read on.

Contents

What is Ethereum?
What is an Ethereum smart contract?
What is “Ethereum Virtual Machine” (EVM)?
What are Ethereum DApps?
Advantages and disadvantages of Ethereum
Ethereum development: Public or private?
Ethereum DApp development (approach #1)
An overview of Ethereum development on Hyperledger Fabric (approach #2)
Implementing approach #2, i.e., Ethereum smart contracts on Fabric
Planning a blockchain software development project involving Ethereum?

What is Ethereum?

Ethereum is a permission-less decentralized public blockchain network. A few quick facts about Ethereum are as follows:

  • It has many similarities with Bitcoin. Like Bitcoin, Ethereum uses a decentralized “Peer-to-Peer” (P2P) network. Anyone can join this network. It also uses modern data encryption and consensus algorithm like Bitcoin.
  • Vitalik Buterin, a versatile talent is the lead creator of Ethereum. He is an expert in mathematics, computer programming, and economics. He is also a scholar and journalist.
  • Buterin worked with several experts like Mihai Alisie, Anthony Di Iorio, Charles Hoskinson, Dr. Gavin Woods, and Joseph Lublin. They worked over several years on Ethereum.
  • They released a whitepaper in 2013, announced the arrival of Ethereum in 2014, and held a crowdsale of Ether (ETH), i.e., the cryptocurrency of Ethereum in 2014.
  • The team launched the Ethereum platform in 2015, enabling developers to create “Decentralized apps” (DApps) using it. Read more about it in “Ethereum”.
  • At the time of writing, CoinMarketCap reports that Ether is ranked second in market capitalization, only after Bitcoin.
  • Many experts consider Ethereum the most important blockchain project since smart contracts and DApps make wider adoption of blockchain possible.

What is an Ethereum smart contract?

Ethereum smart contracts are pieces of code with the following characteristics:

  • Smart contracts are open-source, therefore, they are transparent.
  • They contain “If-Then-Else” statements. Based on fulfillment of predefined conditions, they automatically transfer cryptographic assets from one Ethereum address to another.
  • Smart contracts are stored in the decentralized Ethereum blockchain, therefore, they are tamper-proof.
  • Their execution results are stored in the Ethereum blockchain. This makes the outcome of their execution transparent and irreversible.
  • Developers typically code Ethereum smart contracts using the “Solidity” language. Some also code these using the “Vyper” language.

Read more about Ethereum smart contracts in “Smart contracts: the blockchain technology that will replace lawyers”.

What is “Ethereum Virtual Machine” (EVM)?

Ethereum is a collection of protocols that enables developers to build applications on it.  “Ethereum Virtual Machine” (EVM) is the central component here that executes the code in these applications. Read more about EVMS in “What is Ethereum?”.

EVM can execute code with varying complexity, i.e., the computational requirements of the algorithms vary. Computer science experts consider EVM a “Turing complete” computer. “Turing completeness” refers to a classification of computing systems. These systems have rules for processing and manipulating data. Read more about it in “Turing completeness”.

What are Ethereum DApps?

Ethereum DApps are web apps with the following specific characteristics:

  • The front-end of a DApp can be in any programming language, however, the backend must consist of smart contracts.
  • DApps are open-source, and they are autonomous.
  • Ethereum DApps must run on the decentralized Ethereum blockchain.
  • A DApp must use cryptographic tokens created using a standard cryptographic algorithm.
  • No single user can control a majority of these tokens.
  • All changes to DApps must follow consensus within the user community.
  • Ethereum DApps must store data on the Ethereum decentralized blockchain while following cryptographic standards.

Read more about Ethereum Dapps in “How to convert web app into a DApp”.

Advantages and disadvantages of Ethereum

Ethereum follows all the decentralization, immutability, security standards that Bitcoin boasts of. Additionally, it offers the following advantages:

  • Developers can write smart contracts and DApps that execute on the Ethereum blockchain. This has enabled many entrepreneurs to build new decentralized businesses. The blockchain-crypto industry witnessed over 3,000 “Initial Coin Offerings” (ICOs) in the 2017-18 period. 84.29% of these ICOs used the Ethereum platform. Read more about these statistics in “ICO market 2018 vs 2017: trends, capitalization, localization, industries, success rate”.
  • The success of Ethereum made many enterprises to work with the Ethereum project team. Enterprises need solutions suited to their requirements. They have formed the “Ethereum Enterprise Alliance” (EEA) together, with the objective of helping enterprises adopt blockchain.

There are some drawbacks of Ethereum, as follows:

  • Scalability: While Ethereum provides robust decentralized security, the network doesn’t scale well enough to cater to the growing user base.
  • Energy-hungry consensus algorithm: Like Bitcoin, Ethereum uses the energy-hungry “Proof of Work” (POW) consensus algorithm for transaction validation. Ethereum has a plan of transitioning to the “Proof of Stake” (PoS) algorithm, which isn’t energy-hungry. That will pave the way for dealing with the scalability issue as well. Read more about these algorithms in “Proof of work vs proof of stake comparison”.

Ethereum development: Public or private?

Before you embark on a software development project using the Ethereum platform, you need to decide on using the public vs private blockchain. This matters due to the following reasons:

  • Entrepreneurs trying to set up a decentralized business model can consider the public Ethereum blockchain since it’s permissionless. However, if you are implementing a blockchain application in your enterprise, then you will allow only trusted parties to join. You will need a permissioned blockchain.
  • A business model relying on a completely decentralized transaction validation may find the public Ethereum blockchain attractive. While there are issues with energy consumption and scalability, the Ethereum project team is trying to improve on those counts. However, if you are implementing in an enterprise context, scalability and high transaction throughput are crucial. You will need a private blockchain.

Read more about these differences in “Public vs private (permissioned) blockchain comparison”. I recommend you use the Ethereum DApp approach if you can work with a public blockchain. On the other hand, use Hyperledger Fabric with Ethereum Smart contract capability if you need a permissioned blockchain. I will call them “approach #1” and “approach #2”, respectively. Although “approach #2” doesn’t involve the Ethereum network, it at least includes Ethereum smart contracts.

Ethereum DApp development (approach #1)

Let’s go over Ethereum DApp development, step by step, as follows:

Step #1: Build a team

You need the following roles in your team:

  • UI/UX designer;
  • Ethereum programmers with Solidity skills;
  • Testers;
  • A project manager (PM).

Step #2: Utilize Ethereum development learning resources

Note that Ethereum blockchain development skills are niche, therefore, consider using the following learning resources:

Step #3: Create an Ethereum account and buy Ether

Ether, the native cryptocurrency of Ethereum is the fuel that drives all transactions on the network. You need Ether to deploy smart contracts and run your DApp. You need to create an “Externally Owned Account” (EOA) on Ethereum, which involved the following steps:

  • Use “eth-lightwallet”, an easy-to-use Ethereum wallet.
  • Set it up using their GitHub instructions.
  • Create your public and private keys. Secure the private key, don’t divulge it.

Now, you can buy Ether.

Step #4: Install the required tools

You need the following tools to develop an Ethereum DApp:

  • “testrpc”: It’s an easy-to-use blockchain client, which also provides a “Command Line Interface” (CLI). Install and configure it following its’ GitHub instructions.
  • “Web3.js”: This is an Ethereum JavaScript API to communicate with the Ethereum blockchain network. Use the instructions to install it.
  • “Truffle”: A development environment for Ethereum, Truffle aids in smart contract compilation, linking, automated testing, build management, and deployment. You can install and configure it using the GitHub instructions. You can create folders for your smart contracts.
  • “MetaMask”: You will need to test your smart contracts before deploying them. MetaMask is a browser extension. It allows you to communicate with Ethereum even if you don’t run a full Ethereum node. Install either Chrome or Firefox extension from its’ website. Accept the terms and conditions, create a password, and secure the 12-word private seed for later use. Refer to “How to deploy smart contract on Ethereum?” for more details.

Step #5: Configure the tools

You need to configure the above-mentioned tools as follows:

  • Open “testrpc” and run an instance.
  • Configure the “aconfig.js” file to make Web.js work.
  • Update your “config.js” file with your public and private key information from your “eth-lightwallet” settings. Read “Getting started as an Ethereum web developer” for more guidance.
  • Connect MetaMask to “Ropsten”, an Ethereum test network, which you will use for testing your smart contract. To do this, click the MetaMask mainnet button, and point to Ropsten. Read “Ultimate guide to convert a web app to a decentralized app DApp” for details. Let’s call it the “reference article 1”.

Step #6: Use “Remix” IDE to code smart contracts

You will need to develop the “User Interface” (UI) of your DApp like you would do for any web app. You can develop Ethereum smart contracts in parallel. To do this, use “Remix”. It’s an “Integrated Development Environment” (IDE) for smart contract development. It’s a DApp, therefore, you don’t need to install anything.

Step #7: Test smart contracts in Ropsten

This involves the following actions:

  • Visit MetaMask Ether Faucet to buy dummy Ether. This is required for testing smart contracts in Ropsten. Ropsten is a test network and doesn’t need real Ether.
  • Check and ensure that the MetaMask connection with Ropsten is still open.
  • Go back to Remix, and locate the small “+” sign at the top left, which also has a label “Create”.
  • Click it to deploy your smart contracts to Ropsten, and confirm the action in MetaMask.
  • Test smart contracts.

Read “reference article 1” for more detailed guidance.

Step #8: Deploy smart contracts to the main Ethereum network

Now that you have tested the smart contracts, you will deploy them to the main Ethereum network, as follows:

  • You will use the real Ether you had bought earlier.
  • Ensure that the testrpc instance is still running.
  • Navigate to your Truffle directory.
  • Use the “truffle deploy” command to deploy your smart contracts.
  • Note down your smart contract address, for later use.

Step #9: Create your crypto token

Now that you have built smart contracts, you will be able to use the knowledge to build your crypto token. Note the following points in this regard:

  • You need to code smart contracts to create crypto tokens on Ethereum.
  • Ethereum has various standards for crypto tokens, for e.g., ERC20, ERC721, etc. There are subtle differences between them. ERC20 is the most common standard. You will likely be able to use it for most use cases. Read more about the ERC20 standard in “ERC20 Token Standard”.
  • An Ethereum smart contract for creating a crypto token will need to use a few standard functions like giving all the initial tokens to the creator, check whether the sender has enough balance, check for overflows, subtract from the sender, etc.
  • Such a smart contract will also need to set values for some required fields like token name, initial supply, etc.

Read “Create your own crypto-currency with Ethereum” for detailed instructions to create an Ethereum crypto token.

You have developed, tested, and deployed your Ethereum DApp.

An overview of Ethereum development on Hyperledger Fabric (approach #2)

In an enterprise environment, you need controlled access, data privacy, scalability, and high-transaction throughput. The public permissionless Ethereum blockchain isn’t your option. Hyperledger Fabric, a project from the Hyperledger Consortium is an option.

Why Hyperledger Fabric?

Hyperledger Fabric is a good choice, due to the following reasons:

  • It’s a permissioned enterprise blockchain, therefore, only trusted parties can join.
  • It allows access control. Enterprises can safeguard their sensitive information.
  • Hyperledger Fabric or “Fabric” as it is commonly called provides separate channels for confidential transactions.
  • The consensus algorithm mirrors the organizations’ business transaction workflow.
  • Fabric has high scalability and impressive security features.
  • Fabric is supporting Ethereum smart contract development since late 2018.

Read about the advantages of Fabric in “Pros and cons of Hyperledger Fabric for blockchain networks”.

How does Fabric support Ethereum smart contract?

Fabric now includes the following components to support Ethereum smart contract development:

  • EVM: Developers can now use Hyperledger Burrow on Fabric. Burrow is a Hyperledger project that offers a blockchain client and a smart contract interpreter. The smart contract interpreter uses the EVM concepts, and Fabric developers can code “chaincodes”, i.e., smart contracts in Hyperledger parlance.
  • Accounts: Fabric will use “Contract accounts” (CAs) on the blockchain to store chaincodes. Since there is no cryptocurrency involved here, Fabric will create EOAs on the fly. I had explained this earlier in “Using Hyperledger Fabric to setup Ethereum smart contracts”.
  • Ethereum client: “testrpc”, the blockchain client I have referred to earlier, has a JSON RPC API. Fabric has now incorporated this partially for the EVM implementation. Fabric also uses “Fab3” to incorporate “Web3.js” for its’ EVM implementation. You can read about using Fab3 on Fabric EVM here.
  • “Gas”: Developers need to pay for “Gas” on the public Ethereum blockchain to execute operations, and they use Ether for that. Fabric hardcodes a high-amount of gas to facilitate the execution of operations. Operations will fall within that gas limit, therefore, Fabric EVM developers don’t need to pay using Ether.

Implementing approach #2, i.e., Ethereum smart contracts on Fabric

I will describe the steps to implement Ethereum smart contracts on Fabric, as follows:

Step #1: Form a team

You need the following roles in the software development team:

  • UI/UX designers;
  • Software developers with Fabric and “Go” language skills;
  • Ethereum developers with Solidity skills;
  • Testers;
  • A PM.

Step #2: Install the relevant tools

In this approach, you need the following tools:

  • cURL: You can install this tool for file transfers to and from a server, by following these instructions.
  • Docker: This will help in creating, deploying, and running apps using containers. Install Docker using these instructions. This also installs “Docker Composer”, which you will need to multi-container apps.
  • “Go” language: This is to create your app where you will use the Ethereum smart contracts on Fabric. Follow the installation instructions here.

Step #3: Get helpful samples, binaries, and Docker images

The Fabric project team has made an effort to help developers and has provided some helpful resources. You can install the following and expedite your project:

  • Code samples;
  • Binaries;
  • Docker images.

Step #4: Clone the Fabric EVM chaincode

You will write Ethereum smart contracts on Fabric, therefore, you need the appropriate tool to interact with them. The EVM chaincode, based on Hyperledger Burrow is that tool. Install it following these GitHub instructions.

Step #5: Configure the Fabric EVM chaincode:

Now that you have got the sample project from GitHub in the preceding step, you need to configure it. Take the following steps:

  1. Navigate to the “first-network” folder.
  2. Modify the Docker composer CLI file to map to the folder where you had cloned the sample project from GitHub.
  3. Start the network.
  4. Navigate to the Docker CLI container.
  5. Install the EVM chaincode.
  6. Instantiate the EVM chaincode.

You can read “Solidity smart contract on Hyperledger Fabric”, which contains the detailed instructions and commands.

Step #6: Write smart contracts using the Remix IDE

Write Solidity smart contracts using Remix IDE, just like you had done when you worked on the public Ethereum blockchain.

Step #7: Compile and deploy smart contracts

At this point, you need to take the following steps:

  • Use the Remix IDE to compile the smart contract.
  • Copy the bytecode. You can follow the instructions in “Solidity smart contract on Hyperledger Fabric” that I had referred earlier.
  • Open a text editor of your choice, and paste the bytecode, which is in JSON format.
  • Use the “peer chaincode invoke” process, for deploying the smart contract. Read the syntax of the command here.

This completes the process of developing Ethereum smart contracts on Hyperledger Fabric.

Planning a blockchain software development project involving Ethereum?

Whether you develop an Ethereum DApp or Ethereum smart contracts on Fabric, this promises to be a complex project. These are niche skills, furthermore, you also need a PM experienced with blockchain development. Consider taking professional help. Our guide “How to find the best software development company?” can help you in finding the right development partner.