A smart contract is a piece of code that works with a blockchain to enforce the terms of a particular contractual agreement.
Smart contracts allow trusted transactions to take place between anonymous parties, thereby creating a transaction record that’s transparent, traceable, and irreversible—all the while eliminating the need for third-party middlemen.
Sounds great! But how does a smart contract really work?
What Is a Smart Contract?
Even though smart contracts feel like new technology, they were first proposed back in 1994 by American computer scientist, Nick Szabo. (Nick Szabo is alleged to be Satoshi Nakamoto, the creator of Bitcoin, but he vehemently denies it.) Szabo’s paper theorizes smart contracts as a “computerized transaction protocol that executes the terms of a contract.” Put forth way ahead of their time, many of Szabo’s proposals have now become the central features of a modern smart contract.
Smart contracts help people by facilitating the exchange of things by way of computer code. In a sense, smart contracts are glorified examples of “when X takes place, do Y” code. Blockchain-based contracts bring the control of financial transactions back into the hands of users and vendors (away from institutions like banks) while ensuring there is a permanent record of those transactions.
Unfortunately, the term itself—“smart contract”—causes confusion. When you think of a traditional contract, you think of a signed piece of paper that outlines details of a legal agreement. A smart contract doesn’t just outline but enforces the terms of an agreement using cryptographic code linked to the blockchain.
5 Examples of How Smart Contracts Work
While smart contracts are predominantly associated with Ethereum, Bitcoin has always had basic smart contract support. It’s just that Bitcoin’s limited programming language made it difficult to create worthwhile smart contracts. Ethereum later came in and took up the mantle with smart contracts based on an easier-to-code programming language.
Here are a few examples to help get a better sense of how smart contracts work:
Example 1: You’re running a campaign to create a blockchain-based Kickstarter equivalent (in fact, Acorn Collective—website no longer available—does just this). The smart contract automatically collects fees up until the project funding goal is met, and if the goal isn’t met by the deadline the smart contract returns funds to supporters.
Example 2: The US voting system faces intense scrutiny due to claims of hacking and tampering. A smart contract system using immutable blockchain technology would be more secure than current electronic voting booths. Follow My Vote is a blockchain-based voting platform that “embodies all the characteristics that a legitimate voting system requires: security, accuracy, transparency, anonymity, freedom, and fairness.” Voters use government IDs, a webcam, and a computer to remotely log in and cast their vote.
Example 3: uPort uses Ethereum smart contracts to manage and protect your identity. For instance, if you’re traveling across borders and have uploaded your passport documents to uPort, you can choose to only reveal the information required at passport control, and only after you verify the information the agent is requesting. The contract rejects any attempt to overreach data, limiting the amount of data that can be revealed.
Example 4: A Midasium Contract is a “digital representation of the mutual agreements contained in a traditional real estate contract.” Midasium creates self-executing and self-enforcing real estate contracts that move bank funds, title deeds, and reconcile payments. Midasium contracts remove the need for costly third-party intermediaries. Better still, users can convert their Midasium smart contracts into regular paper contracts at any time for legal purposes.
Example 5: Another great smart contract implementation is the AXA fizzy flight compensation partnership. Instead of having to wait weeks for claims processing, AXA fizzy gives direct compensation. You purchase cheap flight insurance through AXA, who uploads your record to fizzy. In turn, fizzy records your purchase on the Ethereum blockchain. Your smart contract is connected to global air traffic databases, so as soon as your flight is delayed by two hours, compensation automatically triggers.
Once a smart contract is written, it’s uploaded to the Ethereum Virtual Machine (EVM). The EVM is like a universal runtime propagate out to every connected Ethereum node, where each node can check that the conditions of the smart contract have been met. If so, the nodes respond accordingly and carry out the smart contract’s instructions.
Going beyond, smart contracts aren’t just useful as specialized contract tools—they also pave the way for decentralized apps, and that’s one of the main reasons why there’s so much excitement around the ongoing development of smart contracts.
Learn more about this in our What Is a Decentralized App? article.
Can You Trust a Smart Contract?
Remember, a smart contract is:
Smart contracts save money by removing third-party entities from the equation and allowing parties to deal with each other face-toface. Yet while that sounds great in theory, for many people, using a third-party intermediary isn’t always about cost—it’s about security. In the case of a smart contract, how can you trust it if you didn’t write the code for it?
Once the smart contract writes its transaction to the blockchain, it’s publicly recorded for all to see. That record cannot be erased, and anyone can double-check it at any time. But when the smart contract executes, it carries out the instructions exactly as it was coded to do, and it’s this part that has people worried.
In principle, contracts based on “if-then” agreements make sense because there are constant inputs and verifiable outputs that can be confirmed—but the confirmation itself still relies on verification, and in many cases will require human arbitration. That’s when the human factor comes back into play, along with trust issues.
Smart contracts are still young. They aren’t without flaws, and the technology still needs a lot of work.
In fairness, trust in smart contracts can be enhanced with interdependence. In other words, we can create trust in smart contracts with more smart contracts. It’s smart contracts all the way down.
Smart contracts can be set up so that verification of conditions is dependent on the preceding contract, and so on. Also, smart contract oracles can submit real-world data to the blockchain for use in smart contract verification. Smart contract oracles play an important role in smart contract trust, and will continue to do so.
Smart Contracts Are the Future
Smart contracts will become more useful as cryptocurrency and blockchain evolve. The questions being asked of smart contracts are part of that evolution.
Right now, the technology is new and the boundaries are unknown. Regular users (especially those who aren’t already exposed to cryptocurrency and blockchain) might find it difficult to trust digitized contracts that they can’t touch, feel, or even modify after execution. But give it enough time and we’ll soon see the power of smart contracts in action.
Smart contracts are a core function of the Ethereum blockchain—but not for Bitcoin. Why is that? Check out the major differences between Bitcoin and Ethereum, and why they are important.
We earn commission if you purchase items using an affiliate link. We only recommend products we trust. See our affiliate disclosure.