Programmable Money Part 1: Bitcoin and Ethereum

Notional Ventures
8 min readOct 16, 2023

The first article in a three-part series which introduces users to the idea of programmability in blockchains.

Table of Contents

Introduction

In our introduction to the Cosmos, we briefly mentioned that one of the shortcomings of Bitcoin was a lack of programmability. In the spirit of keeping that article cheap and cheerful, we didn’t really expand on what that meant, but there’s actually a lot to unpack.

Understanding how blockchains can support different applications is an important part of feeling confident with the technology, so in this three-part series, we are going to introduce the idea of programmable money and assets on blockchains and later walk through exactly how a Cosmos blockchain can host dedicated applications, and thus be referred to as an appchain.

Let’s dive in.

Bitcoin

What do we mean by programmability, anyways? Let’s start with Bitcoin.

Within the Bitcoin blockchain, there’s really only two things you can do: (1) transfer Bitcoin stored at your address to another address and (2) don’t do that, and leave your Bitcoin sitting where it is. This is a slight oversimplification, but not a big one — Bitcoin is a ‘dumb’ blockchain in that it simply can’t do much¹.

The tradeoff of that ‘dumbness’ is reliable security — very little can go wrong in the process of sending your Bitcoin to someone else, as long as it’s done right. Bitcoin as a very secure digital asset is the decentralized application (or dapp, for short) of the Bitcoin blockchain.

But we can do a lot more with money than just send it to other people. We can lend it, borrow it, invest it, buy stuff with it, and so on. None of these things are possible on Bitcoin.

Sure, you could:

  1. Go to a physical business
  2. Agree on a price in Bitcoin for goods or services
  3. Transfer the Bitcoin to them

But at the end of the day, you have to TRUST that they’ll provide their business after receiving payment. What if we want to minimize that trust? Can we put entire marketplaces on a blockchain? What about more complicated financial interactions like lending and borrowing?

Enter Ethereum

Ethereum introduced the world to the idea of highly programmable money, and innovation continues to thrive there. You may have already used some dapps on Ethereum, but in order to provide context for programmability on Cosmos, we will give a brief overview here.

Just like in all proof-of-stake chains, Ethereum validators must keep a complete copy of the blockchain and run the consensus protocol to ensure that their copy of the transaction history agrees with all other nodes.

But in addition to that, they must run the Ethereum Virtual Machine (or EVM — see these docs for more details²). This is a program that runs on top of the consensus layer and allows for the deployment of smart contracts, which are the smallest building blocks for dapps on Ethereum.

What is a Smart Contract?

First off, a smart contract is neither ‘smart’ in any meaningful sense, nor is it a ‘contract’ in any legal sense, so the name is wildly inaccurate. But, it is also catchy, which is probably why it has stuck.

Smart contracts are defined nicely here, so I will not attempt to reinvent the wheel:

…we use the term “smart contracts” to refer to immutable computer programs that run deterministically in the context of an Ethereum Virtual Machine as part of the Ethereum network protocol³.

Let’s break this down.

Smart contracts are computer programs, just like any program on your computer or phone. But there are a few key differences:

  1. Their code is stored on a blockchain (in this case, Ethereum).
  2. They exist as a contract account, which has a public address but no private key, unlike normal user accounts.
  3. They can’t run at any time, they can only run (or execute) when digital assets (like ETH) are sent to their contract address.
  4. They are deterministic, which means that the outcome of running a smart contract is the same for anyone who runs it in the same context.
  5. They are immutable — they cannot be changed, since their code lives in the immutable history of the Ethereum blockchain.

Smart Contract Example

Let’s imagine a very simple ‘lottery’ smart contract:

  1. Any account can send any amount of ETH to the contract address.
  2. Any account that does will qualify as a ‘participant’ for this lottery.
  3. Once the pool of ETH in the contract address reaches some maximum ‘jackpot’ amount — let’s say, 10 ETH — the jackpot will be distributed to one random participant address.

Here is a step-by-step breakdown of how this comes into existence (and for more details, read through this article⁴) :

  1. I write the code for this contract in a language like Solidity (the most popular smart contract language for the EVM). The jackpot amount and the process for selecting a jackpot winner will be included in this code.
  2. Once I’m certain that it does what I think it does, I sign a contract creation transaction, which will 1) compile the solidity code into bytecode and 2) publish the bytecode to the blockchain, pairing it with a public contract address.
  3. Once that transaction is published in a block, all nodes will update their local transaction histories (and thus have a copy of the bytecode). My contract is now stored as an immutable decentralized program!

(Note: Solidity is referred to as a ‘human-readable’ language whereas bytecode gives the EVM a very clear set of instructions that would be challenging for a human to understand)

Now, suppose our pool currently contains 9 ETH and one final user sends the last needed 1 ETH to this contract address. Let’s look at what happens:

  1. A validator will include the transaction in a proposed block.
  2. The EVM must determine that the transaction is valid and thus that the resulting state of the Ethereum blockchain will be valid after it is confirmed. Assuming our sender has 1 ETH to send, this transaction will be valid and the contract will execute.
  3. The arrival of ETH at the contract address triggers the bytecode and executes the contract. This is how all Ethereum smart contracts are activated — by sending assets to them.
  4. The contract will add the sender’s address to its list of ‘participant’ addresses. Since the new balance is 10 ETH, it will randomly select one of the participant addresses and forward the 10 ETH to that address.

This example application is simple, but hopefully it has given you a glimpse into the basic building blocks of dapps on Ethereum. The EVM is Turing complete which means that any idea that is programmable can be run as an Ethereum smart contract.

At the time of writing, there are all sorts of complex dapps running on Ethereum: marketplaces, games, and financial services are just a few examples and I’m sure the future will see far more.

But if basically anything is possible on Ethereum, what value could the Cosmos possibly bring?

Issues with Ethereum

Despite the tremendous success of the EVM, dapp development on Ethereum has been met with many challenges. Four categories of challenges will help to provide context for programmability in Cosmos, so I will address them briefly here:

Performance: All dapps built on Ethereum must ultimately compete for blockspace. Suppose that an NFT marketplace is having a record day for volume. The sheer number of transactions being processed from that dapp will impact the performance of all other dapps as well. Most likely this will drive up gas fees and slow down processing time.

Flexibility: The EVM has inherent limitations. As examples, only certain cryptographic libraries are supported and only account-based systems (as opposed to UTXO-based systems like Bitcoin) are possible. Additionally, most contracts are written in Solidity, which has its own set of limitations. What if an application requires features that are not available in the EVM, or could be better written in another programming language?

Security: Unfortunately, Solidity is a relatively young language. Best practices and strong security principles for writing smart contracts still leave much to be desired. To date, billions of dollars have been lost or drained from poorly written smart contracts on Ethereum. Just have a look at a few highlights from Rekt News⁵ and Milk Road⁶ for details.

It is important to note that security standards for smart contracts are improving, (for example, see this section in the Ethereum documentation⁷), but will likely remain an issue for some years.

Sovereignty: How “in control” of an application is a team when their dapp is built on Ethereum? Upgrades to the EVM, for example, may introduce issues into existing smart contracts or even render them obsolete.

Ultimately, building on Ethereum also means you are always paying fees in ETH — the blockchain itself may have captured considerable value from your users before you’ve even reached the final version of your dapp.

Is it possible that Cosmos can address any of these issues? Make sure you read the next article in this series to find out!

Thanks for reading ❤
Robin Tunley
Twitter: @the5thforce0_0
Special thanks to Ruslan Akhtariev for his input in this series.

References

[1]: Antonopolous, A. (2016) The Internet of Money, Merkle Bloom LLC

[2]: The Ethereum Book — Introduction: https://github.com/ethereumbook/ethereumbook/blob/develop/02intro.asciidoc

[3]: Ethereum Book, Smart Contracts and Solidity https://github.com/ethereumbook/ethereumbook/blob/develop/07smart-contracts-solidity.asciidoc#what-is-a-smart-contract

[4]: QuickNode, An Overview of How smart contracts work on Ethereum, https://www.quicknode.com/guides/smart-contract-development/an-overview-of-how-smart-contracts-work-on-ethereum

[5]: Rekt News, https://rekt.news/

[6]: Milk Road, https://milkroad.com/hacks

[7]: Ethereum Documentation, Smart Contract Security, https://ethereum.org/en/developers/docs/smart-contracts/security/

If you found this article interesting or informative, please help us out by sharing it with your friends and family. If there are other topics within the Cosmos you’d like to know more about, don’t hesitate to contact us and let us know!

Notional: Website
Notional on Twitter: @notionaldao

--

--

Notional Ventures

High Quality In-House Validation, Relaying, and Software Engineering for the Cosmos.