What are smart contracts? A beginners guide to automated agreements
Smart contracts are essentially automated agreements between the contract creator and the recipient. Written in code, this agreement is baked into the blockchain, making it immutable as well as irreversible. Popularized by the world’s second most popular blockchain, Ethereum, smart contracts have led to the network’s array of decentralized applications (DApps) and other use cases.
One key benefit of blockchain networks is the automation of tasks that traditionally require a third-party intermediary. For example, instead of needing a bank to approve a fund transfer from client to freelancer, the process can happen automatically, thanks to a smart contract. All that’s required is for two parties to agree on one concept.
Another example could be a regulatory group and the citizens it represents debating a law. If these two parties come to an agreement in a blockchain-based system, the law would be put into place via a smart contract. Maybe users could read about the new law via a legal DApp, or interact with it in another blockchain-based way.
History of smart contracts
Believe it or not, smart contracts long predate blockchain technology. While Ethereum, introduced in 2014, is the most popular implementation of the protocol, cryptographer Nick Szabo established the idea in the 1990s.
Back then, Szabo conceptualized a digital currency called Bit Gold. While the asset was never actually launched, this Bitcoin predecessor highlighted the smart contract use case — trustless transactions on the internet. If Web 1.0 was the internet itself and Web 2.0 the presence of centralized platforms, then Web 3.0 is the trustless, automated, user-powered version of the digital space.
Many, including the Ethereum website itself, compare smart contracts to a vending machine. Vending machines serve the purpose of a vendor providing the user with a product, without the need for an actual person to take the money and hand over the item. Smart contracts serve that same purpose but are much more versatile.
Smart contracts have advanced quite a bit over time. They started as simple if-then statements that a programmer can create and implement. However, those with programming knowledge are limited, centralizing these “trustless” contracts. Fortunately, those same developers are working to solve accessibility problems.
Since its inception, developers have made it so smart contracts can be made without coding knowledge. They’re increasing security with different programming languages, creating alternatives like secret contracts and designing ways to automatically store smart contract history in a human-readable format — much easier than using the blockchain to read.
How do smart contracts work?
Think of these contracts as digital “if-then” statements between two (or more) parties. If one group’s needs are met, then the agreement can be honored and the contract is considered complete. Let’s say a market asks a farmer for 100 ears of corn. The former will lock funds into a smart contract that can then be approved when the latter delivers. When the farmer delivers their work, the funds will immediately be released. However, the contract is canceled and funds are reversed to the client if the farmer misses their date.
Of course, the above is a small use case. Smart contracts can be programmed to work for the masses, replacing governmental mandates and retail systems, among other benefits. Moreover, smart contracts would potentially remove the need for bringing certain disagreements into court, saving parties both time and money.
This security is largely due to the underlying smart contract code. On Ethereum, for instance, contracts are written in its Solidity programming language, which is Turing-complete. This means that the rules and limitations of smart contracts are built into the network’s code and no bad actor can manipulate such rules. Ideally, these limitations would mitigate scams or hidden contract alterations. A smart contract can only fall into place if all participants agree and sign on the matter. Then, it’s set for life.
In more technical terms, the idea of a smart contract can be broken down into a few steps. First, a smart contract needs an agreement between two or more parties. Once established, the two can agree on conditions in which the smart contract will be considered complete. The decision would be written into the smart contract, which is then encrypted and stored in the blockchain network.
Once the contract is complete, the transaction is recorded on the blockchain just as any other would. Then, all nodes will update their copy of the blockchain with this transaction, updating the new “state” of the network.
Now, you may be wondering if Bitcoin and other networks can utilize smart contracts. To a point, yes. Every Bitcoin (BTC) transaction is technically a simplified version of a smart contract, and layer-two solutions are in development to expand the network’s functionality. That said, Ethereum’s use of smart contracts is a special case.
Unlike most blockchain networks which are described as a distributed ledger, Ethereum is what’s considered a distributed state machine, containing what’s known as the Ethereum Virtual Machine (EVM). This machine state, which all Ethereum nodes agree to keep a copy of, stores smart contract code and the rules by which these contracts must abide. Since every node has the rules baked in via code, all Ethereum smart contracts have the same limitations.
Where do smart contracts apply?
Aside from the payments example mentioned above, there are various, potential implementations of smart contracts that can automate the world and make it an easier place to live. Here are some prominent examples of smart contract use cases.
On the internet, information is currency. Companies profit off of knowing everyone’s interests and people are not always in control of how that data is acquired, nor do they profit from it. With smart contracts, people are in control.
In a blockchain-based future, identities will be tokenized. Ideally, this would mean each person’s identity exists on a decentralized blockchain, safe and secure from any bad actors. Now, if a user wants to participate on social media or submit documents to a bank for loan purposes, they can profit from the former and control the transaction process in the latter.
For social media, no intermediary controls a network. Instead, users choose which information to make public and which to keep private. Should they want to participate in information exchange, like an endorsement, they can create a smart contract and choose which data is transacted, rather than simply taking everything about the user. A third party isn’t there to take some of the funds or secretly store and sell that data — only the user profits.
The same applies when it comes to dealing with banks and other financial institutions. Communication only involves sending required documents and vital information over. There’s no risk of a loan group storing your email address and selling it to other credit companies. That info is entirely under the user’s control.
In the traditional world, real estate brokers are a necessary evil. Considering the act of selling a house is nothing short of long and convoluted, owners will hire a broker to manage the confusing parts for them, such as the paperwork and finding a buyer. While that sounds ideal for the seller, remember that brokers take a significant fee of the house’s sell price.
A smart contract can take the place of a broker, streamlining the house-transfer process while ensuring it’s just as secure as with an intermediary. This is where the “trustless” moniker comes into play.
Imagine the deed to your house is tokenized on the Ethereum blockchain. If you’re ready to sell it, you’d create a smart contract with the buyer. That contract would hold the deed in escrow until the buyer’s funds are properly submitted. Then, and only then, it will be released.
Everyone wins. The seller saves money as they don’t have to pay an intermediary and the buyer gets the house much sooner than they would have otherwise.
Insurance policies could easily benefit from smart contracts. Essentially, signing up for a policy would enter the user into a smart contract with a provider. All policy requirements would be written into the smart contract which the user would read and sign if they agree.
That contract would sit open until the liable party needs it. Then, they’d simply upload the required forms that prove their need for insurance payment and the funds would be released. This type of contract removes the need for communicating with insurance groups and individuals. While the user would still need paperwork to prove their requirements, the subsequent submission and funding process will be close to instant.
In the identity aspect of things, it’s worth keeping in mind that all drivers will have a record of their accident reports and other important insurance information as well. This accessibility could factor into lower rates for good drivers with no dings on their driving history.
Arguably, one of the most popular implementations of blockchain technology and smart contracts, in particular, is within a supply chain.
Grocery stores, office warehouses, farmers and more all have their specific place in the supply chain. But, with how complex these networks are becoming, companies are finding it increasingly harder to track product custody and follow payments, among other things. Smart contracts can automate and incentivize all parts of the supply chain to increase their accountability.
For example, say a grocery store is waiting on an apple delivery from another continent. It paid for a certain amount of apples and expects that exact number or volume upon retrieval. However, human error can come into effect. Somewhere along the way, workers could have misplaced some apples, stolen them off the line, or simply lied about them all making it to the destination. One party doing this messes up the rest of the chain, and by the time a grocery store receives their shipment, who knows where it went wrong.
With smart contracts, the grocery store could set up an automated check-in at each step of the process. While those check-ins already exist in a normal supply chain, they must be fulfilled manually. A person may have to count the objects and submit what has arrived. They could lie and take some of the product, claiming some was lost along the way. Supply chain theft is a huge problem, costing Americans $35 billion a year.
What’s different with smart contracts is the trustless aspect. The store could set it so payment is not released until all apples are accounted for. There’s no way to mislead this system, so parties will be much more attentive when it comes to supply. Plus, payment will be released instantly to the receiving party which is a great incentive in its own right.
Also, the store could trace which smart contracts aren’t being fulfilled and choose not to work with those parties. Eventually, there could be a whole rating network of clients best to work with and those who aren’t, saving everyone time and money in the long run.
Downsides of smart contracts
While smart contracts are great in concept, they’re certainly not perfect. For one, it’s worth remembering that smart contracts and blockchain networks are programmed by hand. Human error is always possible, and that error could lead to exploits. This is exactly what happened with the attack on Ethereum’s Decentralized Autonomous Organization (DAO) in 2016. Hackers exploited a vulnerability in the DAO’s fundraising smart contract and used it to secrete funds from the project.
That’s not to mention the lack of regulatory clarity when it comes to these autonomous agreements. While the idea of a secure, streamlined money transfer process sounds great on paper, there’s still taxation and other government involvement to consider. Users may want to have full control over their data, but how do governmental parties get what they need?
Also, smart contracts can’t pull information outside of the network in which they exist. At least not in their current state. In other words, you can’t upload data from an existing website to a smart contract on Ethereum. That said, there is a workaround in oracles — off-chain nodes that pull information from the internet and make it compatible with blockchain networks. Eventually, as databases move to the blockchain, oracles could potentially step in to play a role in making that happen.
Additionally, there is a long-standing scalability issue. Since inception, blockchain networks tend to struggle at scale, meaning transactions could take minutes — if not hours — based on activity. While this could be a problem at first, it’s something that projects such as Ethereum 2.0 are looking to solve. Plus, a transaction taking a few hours is still much faster than the days it takes to move traditional funds.