Creating Smart Contracts
Ethereum provides a decentralized virtual computer — the Ethereum Virtual Machine (EVM) — on which developers can build applications consisting of multiple smart contracts. Think of the EVM as a distributed global computer where all smart contracts are executed. (Ethereum is sometimes referred to as a “world computer.”)
Ethereum lets developers program their own smart contracts to define EVM instructions. The EVM executes a contract according to the rules the developer programmed.
Kunal Shah makes it sound a little less dry in this Hacker Noon piece. “Smart contracts live in the form of bytecode within the decentralized database. This is the root of the innovation and disruptive potential of Ethereum.”
Want an explanation from the source? Here’s how the Ethereum white paper explains it:
"The intent of Ethereum is to create an alternative protocol for building decentralized applications, providing a different set of tradeoffs that we believe will be very useful for a large class of decentralized applications […] Ethereum does this by building what is essentially the ultimate abstract foundational layer: a blockchain with a built-in Turing-complete programming language, allowing anyone to write smart contracts and decentralized applications where they can create their own arbitrary rules for ownership, transaction formats and state transition functions.”
(If you need help explaining this concept, we recommend having your colleagues read "How to Explain Smart Contracts to Your Mom." )
Paying with Gas
Whenever smart contract transactions occur within the Ethereum blockchain, it takes computational power to validate them across the network. To compensate for the time and energy it takes to perform those computations, transactions require a fee in the form of “gas” which is paid with ETH (define ETH). The amount of gas depends on the amount of computation required to complete the transaction. This gives developers an incentive to create simple and efficient smart contracts. Moreover, the gas limit — the maximum amount of gas allotted to a particular transaction — means buggy code won’t run indefinitely, costing an infinite amount of gas. (Unspent gas is automatically refunded, but if the transaction runs out of gas, it’s aborted and no gas is refunded.)
Online Casinos as a Use Case
Perhaps not surprisingly, online gaming offers an elegant example of how Ethereum smart contracts work in real life — and illustrates the crucial role of trust. Because smart contracts police themselves, they essentially create trust: A smart contract’s code is transparent and immutable.
So, for our example, smart contracts allow users to publicly verify that a slot game’s historical data is fair and true, explains eth.casino, via Malta Today: “This is because it is literally impossible for an online casino to alter or change the displayed payout ratio, as this process is cryptographically secure.”
That covers the trust. The automated contract execution(if A, then B) also makes it attractive.
“For example, if a roulette player gambles with Ethereum on red (the ‘if’), and the roulette wheel subsequently lands on red, then the smart contract is programmed to automatically return the winnings to the player’s private wallet (the ‘then’). This principle could be applied to absolutely anything in the online gambling sector, from fixed-odds sports, peer-to-peer wagering, to heads or tails. An online casino that can operate in an automated, transparent and secure manner has the ability to earn instant credibility from the gambling community.”
Numerous Ethereum-based gaming sites are up and running, but there are plenty of other applications that deploy Ethereum smart contracts.
Other Ethereum Applications
Developers can use Ethereum to build decentralized apps (dApps) that take advantage of Ethereums’ smart contract technology. Most dApps are built on Ethereums’ blockchain.
The Ethereum white paper outlines three categories of applications:
- Financial applications, providing users with more powerful ways of managing and entering into contracts using their money
- Semi-financial applications, where money is involved but there is also a heavy non-monetary side to what is being done (e.g., self-enforcing bounties for solutions to computational problems)
- Non-financial applications, such as online voting and decentralized governance.
Because Ethereum makes it possible to decentralize any service, the potential applications are almost endless; among them, insurance, retail, microfinance, gaming, virtual worlds, currency exchange, identity-theft protection, financial derivatives, breach contracts, property law, credit enforcement, financial services, legal processes, crowdfunding, voting systems, title registries, and thousands of others.
Here are a handful of examples:
Insurance. French insurance company AXA is testing fizzy, flight-delay insurance. Buy the insurance and if your flight is delayed by the agreed-upon amount of time, you get paid.
Prediction markets. Gnosis and Augur are decentralized predictions platforms. Developers can create a prediction market for any event, such as the Super Bowl or an art auction. People can buy shares in an outcome, and the payout is automatic.
Intellectual property rights. Kodak (yes, that Kodak) is building a digital-rights management platform for photographs. Photographers will register their photos on the KodakOne platform and buyers will purchase rights using the KodakCoin. KodackOne will monitor the web for violations, and promises to "efficiently manage the post-licensing process to reward photographers." (This isn't quite up and running yet: The IPO is scheduled to launch Jan. 31.)
Computer power. The Golem Project is a sharing economy — like Airbnb, but for computing power. Individuals can rent out their unused computing power, or they can buy more power from other users.
This list barely touches on the potential of Ethereum smart contracts. As IBM explains it, ”As the contract is just code, the application is only limited by the developer’s imagination.”
Scalability is a Pain Point
Ethereum isn’t the only blockchain technology to support smart contracts. You can build smart contracts on Hyperledger Fabric using chaincode.
Some observers are completely sold. Sudhir Khatwanim for instance, wrote. “Just like the invention of the Internet has transformed human life, the Ethereum blockchain and smart contracts have the power to change human life in incredible ways.”
We're quite not there yet, but things are moving rapidly. In December, the price of Ether topped $600 for the first time after the announcement that Swiss banking giant UBS would lead an Ethereum-based blockchain platform.
“The news that Ethereum is being used as a base identity layer in conjunction with some of the larger banking giants out there is a positive ratification of the technology,” Charles Hayter, chief executive of digital currency comparison site Crypto Compare, told CNBC.
But, beware of irrational exuberance. Issues abound, most notably, scalability.
Ethereum remains relatively slow at processing transactions. We’ve mentioned this before, and it remains an issue. In fact, it’s even addressed in Ethereums’ white paper:
“One common concern about Ethereum is the issue of scalability. Like Bitcoin, Ethereum suffers from the flaw that every transaction needs to be processed by every node in the network. With Bitcoin, the size of the current blockchain rests at about 15 GB, growing by about 1 MB per hour. If the Bitcoin network were to process Visa’s 2000 transactions per second, it would grow by 1 MB per three seconds (1 GB per hour, 8 TB per year). Ethereum is likely to suffer a similar growth pattern, worsened by the fact that there will be many applications on top of the Ethereum blockchain instead of just a currency as is the case with Bitcoin, but ameliorated by the fact that Ethereum full nodes need to store just the state instead of the entire blockchain history.”
The problem itself is simple and, as the white paper alludes, it’s a blockchain issue, not merely an Ethereum one: Decentralization makes scalability a challenge. Each smart contract and transaction executed on the network must be processed across all the nodes. As if anyone needed a reminder, the Cryptokitties slowdown certainly highlighted the scalability issues.
Developers, of course, are working to address this. In fact, in a Jan. 2, 2018, blog post, Ethereum founder Vitalik Buterin explained that it's become even more critical to speed transaction times. “With the Ethereum blockchain reaching 1 million transactions per day, and both Ethereum and other blockchain projects frequently reaching their full transaction capacity, the need for scaling progress is becoming more and more clear and urgent.”
He announced that the Ethereum Foundation is redoubling its efforts and plans to collaborate with independent developers to improve Ethereums’ scalability.
Speed and scalability aren’t the only issues. Remember, Ethereum smart contracts are still very young — and they are not yet legally binding.
Nigel Montgomery, research director at Gartner, is optimistic about Ethereum, but for now, he has a rather dire warning for business: “Today the technology is immature and mercurial, and once live, the outcome is irrevocable. Smart contracts are something CIOs should invoke at their peril.”
We don’t completely agree: It all depends on the use case. The challenge is knowing when it makes sense for your business and when it doesn’t. That same theory applies to selecting a blockchain platform. Ethereum may be a perfect fit for your organization, but perhaps Fabric is. Or maybe something else.