Bitcoin vs Ethereum smart contracts

This post originally appeared on Medium as part of a two-part series on Bitcoin smart contracts vs Ethereum smart contracts, and we republished with permission from Xiaohui Liu.

Smartphone vs pocket calculator

We compare two smart contract blockchains, Bitcoin and Ethereum, side by side. We find Bitcoin offers superior performance, security, and cost-effectiveness, due to its skillfully constructed fundamental design. This article focuses on their technical differences. Economic, philosophical, legal, and environmental differences are beyond the scope of the article.

Scalability

Ethereum: account model and vertical scaling

EVM

In Ethereum, each smart contracts resides in an account. It has its own storage that persists across contract execution. To see how, let us examine the core smart-contract engine of Ethereum: the Ethereum Virtual Machine (EVM). It is stack based and stores data in three places: stack, memory, and storage. The former two are volatile and ephemeral, meaning they are reset when the EVM starts to run a new contract call. The storage is not reset and is part of the world/global state.

As a consequence, each contract can depend on another one since they may read/write the same storage. Each contract execution sees the world state as it was left by the previous contract execution. There is no concurrency and contracts must be executed sequentially. A single contract is executed at a time to avoid racing conditions.

Ethereum can be considered to be a single-threaded machine, which is limited by the capacity of that machine. In another word, it uses vertical scaling, which is fundamentally flawed for any system designed to support millions of users.

Bitcoin: UTXO model and horizontal scaling

In Bitcoin, smart contracts reside in the so-called Unspent Transaction Outputs (UTXOs). Bitcoin also uses a virtual machine called Bitcoin Virtual Machine (BVM) to process smart contracts that is also stack based. The crucial difference is there is no persistent storage and thus no single global state in BVM. Instead, the global state consists of separate UTXOs, which are independent of each other. Consequently, UTXO is maximally parallel by design.

Bitcoin can be regarded as a pool of machines, all running in parallel. It is horizontally scalable and can scale infinitely by simply adding any number of machines to the existing pool. That is how Google, Facebook, Amazon have proven to scale to support billions of users.

Vertical vs Horizontal Scaling

Bitcoin can process 3000 transaction per seconds (tps) on the mainnet today. On the testnet, 9000 tps has been achieved. With the introduction of Teranode in the coming months, 50,000 tps is expected to be reached. Teranode is supposed to handle terabyte blocks, equivalent to tps at millions level. Ethereum, by contrast, has been stuck at a mere 15 tps for years, with a history of repeated broken promises and no improvement in sight.

Security
Smart contracts deal with assets of real financial value and security is of paramount importance.

Functional/pure vs imperative/impure

Bitcoin’s UTXO model is like functional programming. A contract execution is pure and stateless. It is close to functions in mathematics (e.g., f(x) = x * x). Given the same inputs, a function always yields the same outputs and creates no side effects. This design makes Bitcoin smart contracts much easier to reason and thus less error-prone. Also they can tested accurately off chain since they behave the same, regardless of how, when, and where they are executed.

In contrast, Ethereum’s account model is akin to imperative programming. Each contract call can create side effects affecting another call, making contracts difficult to reason, especially when they become complex. Due to this vulnerable design choice, it has been plagued by tens, if not hundreds, types of attacks, resulting in loss of hundreds of millions of dollars.

Cost

Ethereum vs Bitcoin SV Avg. Tx Fee: Log Scale

Thanks largely to its unbounded scalability, smart contracts running on Bitcoin enjoy 1000X cheaper transaction fees than same ones running on Ethereum¹.

Ecosystem maturity

Bitcoin has only re-enabled smart contracting capabilities in 2020 over a year ago, while smart contracts on Ethereum have been developed since 2015. Given its 5-year head start, it is no surprise that the ecosystem on Ethereum is more mature today, in terms of developer tools, libraries, and applications. However, many developer tools in Bitcoin are quickly catching up to and sometimes even surpassing their counterparts in Ethereum. For example, the most popular IDE in Bitcoin supports debugging, deploying and testing, while its counterpart in Ethereum supports none. It is only a matter of time for Bitcoin ecosystem to catch up and flippen Ethereum, given the latter’s inability to scale.

Summary

We conclude Bitcoin is a better platform to build smart contracts on.

Bitcoin vs Ethereum

[1] This assumes a typical smart contract transaction is ~10x the size of a normal bitcoin transfer transaction

New to Bitcoin? Check out CoinGeek’s Bitcoin for Beginners section, the ultimate resource guide to learn more about Bitcoin—as originally envisioned by Satoshi Nakamoto—and blockchain.