This is the first of a multi-part series exploring smart contracts. It will explore the concepts and history of smart contracts, and go into depth for several specific use cases of smart contracts. This series is aimed at beginners, and will go over all of the necessary foundational information required to understand smart contracts. Although several platforms exist to deploy smart contracts to, this series will focus on the Ethereum blockchain.
So, what is a smart contract? Simply put, a smart contract is a piece of software that stores the negotiated terms of a contract, and then automatically executes those terms. This is a very powerful innovation in peer-to-peer interaction, and has the potential to profoundly disrupt both law and business. The innovative power of the technology cannot be overstated, and this concept cannot be compared to legal contracts as we know them. A legal contract explains to an outside arbiter what the agreement was beforehand, so that if (when) that agreement is not met by one or more parties, that third party can intervene and award reparations based on the recorded terms of the agreement and their discretion. This is a messy and often expensive way for businesses or individuals to operate, and within this framework the explicit agreement is only referred to should their be a perceived deviation from it.
A smart contract, takes the terms that were agreed to beforehand by both parties, and ensures the execution of them. No one can intervene, no one can use asymmetrical power structures to abuse agreements made in good faith, and because smart contracts are deployed to a blockchain, there is a timestamped proof of the contract that is held in a decentralized way by thousands of nodes acting as impartial third parties around the world.
The term “smart contract”, and its underlying concept was first coined by Nick Szabo, cryptographer and expert in digital currencies in 1994. He envisioned smart contracts as “a set of promises, specified in digital form, including protocols within which the parties perform on the other promises". The contracts taking a digital form instead of the typical form, written on paper and enforced in courtrooms offer a very significant difference. Collapsing the terms of the agreement, and the execution of that agreement into a single operation is significantly more efficient than legacy alternatives. It most certainly will save money, because these agreements can be drawn up and deployed without expensive legal counsel, but it will also save the time of parties on the potential wrong end of a dispute. Ensuring from the outset that established rules cannot be broken ensures that all parties involved are negotiating in good faith, because it is enforced by code.
The ultimate purpose of Solidity, as previously mentioned, is to be a high-level programming language to build smart contracts. The Solidity code is put through a compiler, there are also several implementations of the compiler if you have any specific preferences. The compiler outputs opcodes, which are a low-level language, similar to assembly code, which is for the consumption of the Ethereum Virtual Machine (EVM). The EVM is a computer, built into the Ethereum blockchain that executes opcodes, thus performing the functions that are built into smart contracts. In order to prevent nefarious or poor code from disabling the network with an infinite loop and stalling all of the nodes running the code, which in the case of decentralized blockchain would be all of them, the concept of Gas and paying for the computation used was built into Ethereum. These are very complex topics, and entire article series’ could be written about each of them, so if I’ve stirred your curiosity I encourage you to do more research.
I’ve tried to cover the foundational topics of smart contracts as they relate to the Ethereum blockchain without adding unnecessary complication to avoid confusion. However, if you are like me and benefit from an experiential approach to learning the rest of the series will be of interest. Over the next several parts of the series I will go over building and deploying smart contracts from very basic “hello world” contracts, to escrow contracts, coins and more, so please check back often.