Comparative Analysis of Fundamentals and Smart Contract Transactions on EOS and Ethereum Blockchain (Part 2/2)
By: Ren
Tags: Blockchain, Eos, Smart Contracts, Blockchain Technology, Ethereum

Disclaimer: public Blockchain technology develops very fast. The information in this article about EOSIO and Ethereum only refers to their status when the article was written. The purpose of this article is to give an overview of the differences between Ethereum and EOSIO. The author supports all public blockchain projects and thinks that the market can accommodate more than one public blockchain platform.

To read the first part of the article, please click here.

4 Smart Contract on Ethereum and EOS Blockchain

In order to assess the advantages and disadvantages when developing smart contracts on Ethereum and EOS, two smart contracts were built and deployed on the Ethereum Ropsten testnet and EOS Jungle testnet respectively. The first smart contract records location information on the blockchain. The second smart contract deploys a token on the blockchain. These two use cases were chosen for two reasons:

· Already existing experience of the author with adding location information on blockchains from previous projects.

· These are basic and easy to implement smart contracts, and they represent two of the most common uses cases of blockchains: recording data and public crowdfunding.

4.1 Ethereum

4.1.1 Contract development

To develop a simple smart contract that can be deployed on Ethereum, users can start by following a “hello world” example in Solidity to understand the basic principles. It is usually fairly easy to find solutions on the internet if one encounters problems while writing a smart contract. Questions posted on platforms such as Github and Stack Overflow often get answered quickly. Generally, contract development on Ethereum is a fairly easy process, even for people with no or little experience. Due to the large user base and free tutorials, use cases are usually kept up to date. However, this is mainly the case for simple projects such as record data on-chain or token deployment. For more advanced projects, up-to-date tutorials and other information are usually only available in the form of paid tutorials.

The code to track location information in a smart contract on Ethereum is as follows:

Location smart contract

We can see that the contract code is fairly easy to read as it follows the structure mentioned in section 3.1.1. The modifier created in this example is to allow only the owner to execute certain functions. It can also be incorporated into the file. However, in this case, it was put in a separate contract called Ownable.sol, so that it is easier to import the modifier again when writing other contracts.

To write a contract to create a token is very complex. In order to simplify the process, an existing library is downloaded and used. As a result, the token contract code looks a lot simpler than the location contract:

Token smart contract

However, we should always keep in mind that when we use open source code online, there is no guarantee that the code is 100% secure. Extensive tests and code audits should be undertaken to avoid vulnerabilities.

4.1.2 Contract compilation and deployment

There are two ways to compile an Ethereum smart contract: in the local code editor or using the online integrated development environment (IDE) Remix.

If a smart contract is developed in the local code editor, then the use of Command or Terminal is needed for compilation and deployment. This can be a bit of a

challenge for a beginner because knowledge of Truffle is needed. Truffle is a development environment and testing framework for Ethereum which allows local and testnet development and testing of smart contracts. There is a wide selection of tutorials available for the different functions of Truffle. However, for beginners with limited experience, it can be time-consuming to set everything up correctly.

By contrast, the online browser-based Ethereum IDE Remix is a very easy to use application that does not require users to manually enter commands. Compilation and deployment of a smart contract happen via the click of a button. Another advantage is due to its debug and unit test functions, users can find errors in their code much faster. However, there are also downsides. IDE Remix does not support front-end testing and development. If a developer wants to connect the smart contract to a front-end user interface, it can only be done using Truffle. This means that the deployment of more complex smart contracts requires users to have a deeper understanding of different development and testing environments.

In order to deploy an Ethereum smart contract, an ABI is needed. ABI stands for application binary interface. It connects the user programs and operating system. Machine code can be encoded and decoded through the ABI. The ABI is very important when it comes to contract deployment because contract calls are encoded using .abi files for the EVM. When we want to read data from transactions on the blockchain, the ABI is also essential. An ABI includes function descriptions and events and is in the form of a JSON array (Antonopoulos & Wood, 2016/2018).

When the contract is compiled, a JSON file is generated for each of the .sol files under the build/contracts folder, when the contract is developed locally in a code editor. The following figure shows part of the ABI for the location contract written for this article:

Figure 10: Part of ABI of Ethereum Location Contract

4.1.3 Cost

The cost of deploying smart contracts and sending transactions fluctuates in USD. According to the Ethereum Yellowpaper (Wood, 2020), it costs 32000 Gas to deploy a smart contract plus 200 Gas per byte of the source code. The following diagram shows a comparison between Gas price and Ether price. The upper chart shows the average daily Gas price in Gwei (1 gwei = 10^(-19) Ether). The lower chart shows the price of Ether in USD. We can see that the price of both Gas and Ether fluctuates a lot, resulting in unstable dollar costs of deploying and interacting with smart contracts.

Figure 11: Gas price vs Ether price (Ethereum Price, Marketcap, Chart, and Info, n.d.; etherscan.io, n.d.)

Figure 11 shows the details of the location recording contract that was deployed on the Ethereum blockchain. We can see the fee is not high. Even if calculated with the all-time-high Ether price at the beginning of 2018, which was approximately 1400 USD per Ether (see figure 10), the deployment cost would still be under 1 USD (0.00055928 * 1400 = 0.78).

Figure 12: Location contract deployment details

As part of the analysis, two locations were recorded on the testnet. Below is the information on the transactions. For an easy comparison, the details of the locations were added on the bottom right corner of each screenshot and the fees used in each transaction were highlighted.

Figure 13: Block showing location 1 is recorded

Figure 14: Block showing location 2 was recorded

We can see that the cost of recording the first location is significantly higher but converted to USD, the fee paid to record each location is still low. On average approximately 0.15 USD for each transaction. For a company that needs to track the location of 1000 machines and record the location five times a week, it would cost more than 700 USD assuming Ether price stays at a stable level of 1400 USD. If the price of Ether is 350 USD, then the total cost would only be a little more than 200 USD.

4.2 EOSIO

4.2.1 Contract development

Because EOSIO smart contracts use C++ which is familiar to many developers. This makes it easy to learn for many experienced users how to program a smart contract on EOSIO. A simple smart contract in C++ includes two files: .hpp and .cpp, where the .hpp file is where the contract is defined and includes all the function names and class. The .cpp file includes all the logic of the functions listed in the .hpp file. In EOSStudio example contracts such as eosio.token and eosio.system are provided for references.

EOS was launched only a few years ago and saw several updates since then. However, many of the free tutorials being available are out of date and are not compatible with earlier versions of the network. As with Ethereum, access to most of the more advanced tutorials or code examples is paywalled.

The location contract written for this article includes three files: location.hpp, location.cpp and info.hpp.

Below is the location.hpp file where the contract name is defined and functions are listed as actions.

Below is the location.cpp file where all functions are written.

The details of the table were put in another file called info.hpp, where “info” is the name of the table:

Compared with the Ethereum Solidity contract, we can see that the EOS smart contract has a more complicated structure because there are more files to maintain. Also, the C++ code is not as easily readable as Solidity code for someone who has not much knowledge in C++.

4.2.2 Contract compilation and deployment

EOSIO provides a graphic IDE called EOSStudio which can be downloaded for contract development, compilation, and testing. At the moment it only supports local node and cannot be connected to testnets yet.

During the contract compilation process, two files will be generated: an .abi file which is similar to the Ethereum JSON file, and a .wasm file which is a binary file.

There are two ways to deploy a smart contract on a testnet. The first is through a terminal, the second is through uploading files on a website. When deploying through the terminal, it has to be done in a Linux or macOS operating system. This can be an additional hurdle for beginners with only a Windows operating system because a virtual machine is needed or an additional Linux system needs to be installed.

Also, it is worth noting that each account in EOS can only be used to deploy one smart contract. If a second contract is deployed with the same account, then the previous deployed smart contract will be removed.

A useful aspect of EOS is that the data is organized in tables due to its smart contract structure. One can see the table from the block explorer directly. However, this can also be a downside, because when recording sensitive information, encryption is needed.

Figure 15: Location contract table on Jungle Testnet

4.2.3 Cost

As mentioned in the first section, there is no transaction fee on EOS. However, when deploying a smart contract, the contract owner not only needs to buy RAM on the EOS network, staking EOS for both CPU and NET is also necessary. It is difficult to estimate how much RAM to buy and how much to stake for inexperienced users. The screenshots below show how much resources are used for deploying a location contract and token contract respectively. The total amount of RAM was bought with 30 EOS. 1 EOS was staked for CPU and NET respectively.

Figure 16: Resources used for deploying location contract on EOSIO

Figure 17: Resources used for deploying token contract on EOS

RAM price also fluctuates. In the following diagram, the upper chart shows RAM price in EOS, the lower one shows EOS price in USD from the time frame March 2019 to September 2020. We can see that EOS RAM price correlates with EOS price.

Figure 18: EOS RAM price vs EOS price (EOS Authority, n.d.; EOS Price, Marketcap, Chart, and Info, n.d.)

4.3 Advantages and Disadvantages

A summary of the advantages and disadvantages of Ethereum and EOS is shown in the table below:

Table 1: Advantages and Disadvantages of Ethereum and EOS

5 Conclusion and Outlook

In practice, efficient development and implementation of smart contracts for users with limited programming knowledge are based on two factors:

· the availability of full, up-to-date tutorials, sample codes, and other resources

· the availability of stable environments to implement and test smart contracts on different platforms with little effort

In both cases, Ethereum, with its larger ecosystem and more sophisticated solutions, leads the way.

All been said, blockchain and smart contract development are still at a very early stage. There are still a lot of problems to be solved before they can reach wide adoption. However, the technology is also experiencing fast developments every day. In Ethereum 2.0 and EOS 3.0, we can look forward to solutions in the following aspects:

· Sharding in Ethereum 2.0, which aims to achieve increased scalability without sacrificing much decentralization. Increased scalability also means higher transaction speed.

· Interoperability and cross-chain solution in EOS 3.0: one blockchain can validate what happened on another blockchain.

· Better user experience, such as easier to create accounts on EOS, lower transaction fees, better liquidity, which means users can buy EOS more easily.

· More resilient: when a considerable number of nodes go offline, the network still functions normally.

I hope this article provided a clear comparison for people who are undecided about whether to use Ethereum or EOS. We should keep in mind that there is no “best” blockchain. The market needs decentralized blockchain projects with different characteristics, such as consensus algorithms, fundamental architecture, programming languages, etc. Internet and smartphones have transformed our lives. Blockchain will do the same. As the founder of Ethereum Vitalik Buterin once

said: “instead of putting the taxi driver out of a job, blockchain puts Uber out of a job and lets taxi drivers work directly with the customers.”

References

Accounts And Permissions. (n.d.). EOS Developers Documentation. Retrieved July 30, 2020, from https://developers.eos.io/welcome/latest/protocol/accounts_and_permissions, https://developers.eos.io/welcome/v2.0/protocol/accounts_and_permissions

Alharby, M., & van Moorsel, A. (2017). Blockchain Based Smart Contracts: A Systematic Mapping Study. 125–140. https://doi.org/10.5121/csit.2017.71011

Antonopoulos, A. M., & Wood, G. (2018). Mastering Ethereum. O’Reilly Media. https://github.com/ethereumbook/ethereumbook (Original work published 2016)

Block, E. C. (2020). Bloks.io. https://bloks.io

Bosamia, M., & Patel, D. (2018). Current Trends and Future Implementation Possibilities of the Merkel Tree. JCSE International Journal of Computer Sciences and Engineering, 6(2018–8–8). https://doi.org/10.26438/ijcse/v6i8.294301

Brickwood, D. (2018). Understanding Trie Databases in Ethereum. Medium. https://medium.com/shyft-network-media/understanding-trie-databases-in-ethereum-9f03d2c3325d

Buterin, V. (2013). A NEXT GENERATION SMART CONTRACT & DECENTRALIZED APPLICATION PLATFORM. 36.

Chadha, B. (2018). Understanding Vyper: The slick New Ethereum language. Blockgeeks. https://blockgeeks.com/guides/understanding-vyper/

Cleos. (n.d.). EOS Developers Documentation. Retrieved July 30, 2020, from https://developers.eos.io/manuals/eos/latest/cleos/index, https://developers.eos.io/manuals/eos/v2.0/cleos/index

Dataflair Team. (2020). Advantages and Disadvantages of C++. https://data-flair.training/blogs/advantages-and-disadvantages-of-cpp/

EOS Authority. (n.d.). Manage CPU/NET/RAM. EOS Authority. Retrieved September 22, 2020, from https://eosauthority.com/wallet/ram

EOS New York. (2018). The EOS Mainnet Launch: A New Dawn. https://medium.com/@eosnewyork/the-eos-mainnet-launch-a-new-dawn-fa0b5d0fea06

EOS New York. (2019). Managing your EOS Owner & Active Permissions. Medium. https://medium.com/eos-new-york/managing-your-eos-owner-active-permissions-c76bdaf24e6b

EOS price, marketcap, chart, and info. (n.d.). CoinMarketCap. Retrieved September 22, 2020, from https://coinmarketcap.com/currencies/eos/

Ethereum 2.0 Phases. (n.d.). EthHub. Retrieved August 19, 2020, from https://docs.ethhub.io/ethereum-roadmap/ethereum-2.0/eth-2.0-phases/

Ethereum price, marketcap, chart, and info. (n.d.). CoinMarketCap. Retrieved September 22, 2020, from https://coinmarketcap.com/currencies/ethereum/

etherscan. (2020). Ethereum Blockchain Explorer. Ethereum (ETH) Blockchain Explorer. http://etherscan.io/

etherscan.io. (n.d.). Ethereum Average Gas Price Chart | Etherscan. Ethereum (ETH) Blockchain Explorer. Retrieved September 22, 2020, from http://etherscan.io/chart/gasprice

Franco, P. (2015). Understanding Bitcoin. https://www.academia.edu/36423280/_Pedro_Franco_Understanding_Bitcoin_Cryptography_BookSee.org_

Hafid, A., Hafid, A. S., & Samih, M. (2020). Scaling Blockchains: A Comprehensive Survey. IEEE Access, 8, 125244–125262. https://doi.org/10.1109/ACCESS.2020.3007251

Keosd. (n.d.). EOS Developers Documentation. Retrieved July 30, 2020, from https://developers.eos.io/manuals/eos/latest/keosd/index, https://developers.eos.io/manuals/eos/v2.0/keosd/index

Kim, K. (2018). Modified Merkle Patricia Trie — How Ethereum saves a state | by Kiyun Kim. Medium. https://medium.com/codechain/modified-merkle-patricia-trie-how-ethereum-saves-a-state-e6d7555078dd

Konstantopoulos, G. (2017). Understanding Blockchain Fundamentals, Part 1: Byzantine Fault Tolerance. Medium. https://medium.com/loom-network/understanding-blockchain-fundamentals-part-1-byzantine-fault-tolerance-245f46fe8419

Kumar, V. (2020). WebAssembly: Easy explanation with code example. Medium. https://medium.com/front-end-weekly/webassembly-why-and-how-to-use-it-2a4f95c8148f

Larimer, D. (2018). EOS.IO Technical White Paper V2. GitHub. https://github.com/EOSIO/Documentation

LiquidEOS. (2018). CPU, NET & RAM — The raw materials of the EOS economy. Medium. https://medium.com/@liquideos/cpu-net-ram-the-raw-materials-of-the-eos-economy-c4f85022fae

McCallum, T. (2018). Diving into Ethereum’s world state. Medium. https://medium.com/cybermiles/diving-into-ethereums-world-state-c893102030ed

Nodeos. (n.d.). EOS Developers Documentation. Retrieved July 30, 2020, from https://developers.eos.io/manuals/eos/latest/nodeos/index, https://developers.eos.io/manuals/eos/v2.0/nodeos/index

Platform And Toolchain. (n.d.). EOS Developers Website. Retrieved July 20, 2020, from https://developers.eos.io/welcome/latest/overview/platform_and_toolchain, https://developers.eos.io/welcome/v2.0/overview/platform_and_toolchain

Polar. (2018). What is CPU? What is RAM? And How Does the EOS blockchain Utilize These Resources? Medium. https://medium.com/@polar_io/what-is-cpu-what-is-ram-and-how-does-the-eos-blockchain-utilize-these-resources-a7a52e158652

Potter, J. M. (2018). The Problem with Solidity. Medium. https://medium.com/@XBY_Today/the-problem-with-solidity-be7e6c277a58

Priyadarshini, M. (2018, November 16). The Huge Security Problem With C/C++ And Why You Shouldn’t Use It. Fossbytes. https://fossbytes.com/security-problem-with-c-c-and-why-you-shouldnt-use-it/

QuillHash Team. (2019). EOS Smart Contract Development: Understanding fundamental concepts for writing dApps on EOS. Medium. https://medium.com/quillhash/eos-fundamentals-for-developers-essential-concepts-for-starting-eos-development-9d8e1a263724

Release Notes — Vyper documentation. (n.d.). Vyper Documentation. Retrieved August 10, 2020, from https://vyper.readthedocs.io/en/stable/release-notes.html

Rosic, A. (n.d.). What Is Hashing? [Step-by-Step Guide-Under Hood Of Blockchain]. Https://Blockgeeks.Com/. Retrieved June 11, 2020, from https://blockgeeks.com/guides/what-is-hashing/

Rosic, A. (2018). What is Ethereum Gas? [The Most Comprehensive Step-By-Step Guide Ever!]. Blockgeeks. https://blockgeeks.com/guides/ethereum-gas/

Solidity — Solidity 0.7.1 documentation. (n.d.). Solidity Documentation. Retrieved August 23, 2020, from https://solidity.readthedocs.io/en/latest/index.htm

Structure of a Contract — Solidity 0.7.1 documentation. (n.d.). Solidity Documentation. Retrieved August 23, 2020, from https://solidity.readthedocs.io/en/latest/structure-of-a-contract.html

Swamy, A. (2018). Pros and Cons of Solidity. SixPL. https://sixpl.com/pros-and-cons-of-solidity/

Szabo, N. (1997). The Idea of Smart Contracts. https://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/idea.html

Transactions Protocol. (n.d.). EOS Developers Documentation. Retrieved August 9, 2020, from https://developers.eos.io/welcome/latest/protocol/transactions_protocol, https://developers.eos.io/welcome/v2.0/protocol/transactions_protocol

Visa Fact Sheet. (2017, August). https://usa.visa.com/dam/VCOM/download/corporate/media/visanet-technology/aboutvisafactsheet.pdf

Voshmgir, S. (2019). Oracles. In Token Economy: How Blockchains and Smart Contracts Revolutionize the Economy. https://www.amazon.de/gp/product/3982103827/ref=as_li_tl?ie=UTF8&tag=sherminde01a-21&camp=1638&creative=6742&linkCode=as2&creativeASIN=3982103827&linkId=4753362f5226a8282b281de67ec80077

What Is a Blockchain Consensus Algorithm? (n.d.). Binance Academy. Retrieved August 19, 2020, from https://academy.binance.com/blockchain/what-is-a-blockchain-consensus-algorithm

Wood, G. (2020). ETHEREUM: A SECURE DECENTRALISED GENERALISED TRANSACTION LEDGER. 39.

Zhang, E. (2019). Roadmap of NEO 3.0 Development. Medium. https://medium.com/neo-smart-economy/roadmap-of-neo-3-0-development-e2ae64edf226

Zhang, R., Rui Xue, & Liu, L. (2019). Security and Privacy on Blockchain. ArXiv:1903.07602 [Cs]. https://doi.org/10.1145/3316481