Smart contracts are often described as a transformative new technology that borders on magic, able to remove third-parties and monetary risk alike from business deals using the power of the blockchain. The autonomous execution and enforcement of an agreement may sound like something out of a Harry Potter novel, but the maturation of blockchain-based programming techniques have made smart contracts more of a reality than ever.
Smart Contracts in Theory
Many types of business transactions today require intermediate parties to facilitate the exchange of goods or services. These intermediaries are necessary in business deals in order to verify that no single party violates the terms set forth in the contract governing an exchange, especially in deals involving a high degree of mistrust. A new school of thought has emerged around such business deals wherein the contract is digitized and its enforcement is automatic, a strategy commonly known as a “smart contract”. As Nick Szabo first defined in 1994, smart contracts are digital agreements built “in such a way as to make breach of contract expensive (if desired, sometimes prohibitively so) for the breacher.”
The idea of digitizing agreements that previously required third-party oversight is immediately useful in theory, but who drafts such contracts, how are they executed, and who enforces them?
Smart Contracts in Practice
At their core, smart contracts are computer programs that are written by software developers. These programs define functions that can be used to interact with the contract and to change its underlying state, just like traditional programs. However, unlike traditional programs, smart contracts are hosted on decentralized blockchain servers instead of on centralized private servers.
This difference in how smart contracts are hosted is foundational to their increased security over traditional programs: contract code is stored and executed on each individual computer that makes up a given blockchain network. This means that it’s impossible for a malicious actor to shut down, change, or manipulate the program’s execution in any way as long as the underlying blockchain remains stable. Further, smart contract code cannot be modified after its initial deployment, not even by the author of the contract itself. This means that the rules set forth in a smart contract are immutable, and any change to an existing contract requires that a new contract be created and agreed to by all participating parties. This is very important when codifying high-value agreements between parties, as they can rest assured that the terms originally agreed to will remain intact for the lifespan of the underlying blockchain. This is a guarantee that’s impossible to make using a traditional privately-hosted program architecture.
The ownerless manner in which smart contracts are deployed, coupled with the immutability of their source code, are key characteristics that make smart contracts safer and more cost-effective for automating high-value transactions than traditional programs.
Outcome Enforcement
Because smart contracts are computer programs, they don’t actually carry any inherent legal or real-world weight on their own. This realization usually leads to an immediate question: Who enforces the rules set forth in a smart contract? Just like a real contract, a smart contract essentially defines a web of if/then statements that describe the boundaries of a given deal; however, unlike a real contract, a smart contract can take automated, programmed actions when one of those clauses is met, thus giving smart contracts their “smartness”.
This means that the actual enforcement of smart contract outcomes must be programmed into the protocol that they expose. Contracts should be thought of as programmable state machines, only able to call out to other smart contracts or to real-world enforcement mechanisms if necessary. As a basic example, a smart contract could exist between a cell phone company and a subscriber. If the subscriber stopped making payments, a well-written contract could automate an API call that sends a payment reminder text message to the subscriber. If the subscriber continues to miss payments, the contract could disable the subscriber’s service altogether. In this example, the underlying smart contract would be created by the cell phone company, and the subscriber would first agree to all terms that will be codified. The key difference between a traditional cell phone contract and this smart cell phone contract is the automated manner in which it behaves, void of subjectivity, or the involvement of a debt collector or other intermediary.
An Example: Mortgages
We’ve discussed theoretical and practical smart contract implementations, their differences from traditional programs, and their enforceability. Let’s shift to analyzing a smart contract using a real-world example of securing a home loan.
Lawyers would first draft text-based terms to be presented to the borrower that define the agreement being entered into. The contract itself would define a protocol that must be followed by the borrower to retain ownership of a given house. The same lawyers would then work with a programmer to codify those terms in an accurate, enforceable manner. The first key clause of the contract between a lender and borrower would define the required down payment, a payment due date, and an account to transfer to. If closing costs are not transferred to the defined account by the defined due date, the contract notifies the lender and the borrower and the deal is voided. The next key clause of the contract would define a monthly payment, a monthly due date, and an account to transfer to. If the correct monthly payment is not transferred to the defined account by the monthly due date, the borrower is notified and a late-fee penalty is added to the already-due payment. If the next payment is missed, the ownership of the house would be immediately transferred back to the lender.
The example described above is very similar to a traditional contract-based lending process with the exception of the digitizing of the contract and its terms. Because the contract’s terms exist as a computer program, it can take automated actions that are programmed and agreed to in advance by both the lender and the borrower. This smart contract-based approach mitigates legal foreclosure proceedings altogether since a notion of ownership and a failed payment mechanism exist in the very protocol that’s exposed, making future legal oversight unnecessary. If the physical keys to the house were digitally paired with the notion of ownership defined in the contract, this theorized lending smart contract becomes even safer.
Real-world Considerations
Up to this point, we’ve described a seemingly-perfect evolution to traditional contracts whereby most aspects of the contract are automated, and the contract code cannot be changed after the party agreement and initial deployment. While these aspects of automation and immutability give rise to the underlying power of smart contracts, they also pose a very real challenge to smart contract adoption: non-technical parties engaged in a business deal using a smart contract must rely on a trusted third-party to read, verify, and validate the contract’s legal and programmatic correctness. This is a very large departure from traditional contracts that are human-readable even without a lawyer’s help. Without a programmer’s oversight, how can someone agreeing to a smart contract be sure that the underlying code accurately reflects the agreement being entered into? Because smart contracts are computer programs, they require specialized programmatic knowledge to understand their codified logic, so careful and trusted analysis of the underlying code is pivotal to securing a contract’s safety for all participants.
Similarly, the fact that smart contracts stay live and accessible by design as long as the underlying blockchain exists removes all subjectivity from contract execution and enforcement. This is a double-edged sword, both giving power to smart contracts as truly immutable agreements, while also potentially limiting their real-world application. If a participant in a traditional contract violates any terms, it’s up to other parties in the agreement to take recourse against the breacher, and they could subjectively choose not to. Smart contracts instead take the same, pre-programmed, objective action in response to a breach, regardless of subjective circumstances surrounding the violation. Imagine a cell phone subscriber who missed one payment due to an employment change, but their cell service is shut off despite the cell company being amenable to late payment in this case. The perpetual, objective execution of smart contract logic is another departure from traditional contracts and must be treated with great care.
Supporting Blockchains
All blockchains are decentralized and immutable by definition, but not all blockchains organically support smart contracts or the same level of programmability. The Ethereum blockchain is often described as the most mature smart contract platform to date and offers a Turing-complete set of built-in APIs or “opcodes” to support many common programming paradigms. This has given rise to a complex ecosystem of smart contract utility libraries, further increasing the speed at which smart contracts can be developed. Comparably, the Bitcoin blockchain supports very few programming-oriented opcodes, and as a result, is not widely known for its smart contract support. This means that only rudimentary smart contracts that must rely on off-chain logic can be implemented using Bitcoin. And while Ethereum and Bitcoin are two of the most popular blockchain networks, many others have arisen with a specific goal of facilitating the creation of complex smart contracts using simple, high-level languages. Popular platforms include Hyperledger Fabric, NEO, and Tezos, among many others.
Conclusion
As more of the world’s infrastructure is digitized each day, more complex relationships can be formalized with that infrastructure through well-designed smart contracts that sit on resilient blockchain networks. Because of the programmatic and immutable nature of these contracts, they can be trusted to always execute their codified logic in a way that’s immune from both subjectivity and external influence. Traditional text-based contracts have existed for thousands of years, with smart contracts representing the next logical advancement of contractual obligation in a digital age.
Learn more with a walkthrough of our smart contracts tutorial!
Moving Forward With Your Project
SitePen also has extensive experience in:
- Full-stack JavaScript & TypeScript development
- UI | UX design
- Legacy App Re-engineering & Modernization
- Performance optimization
- Technical consulting and advisement
Feel free to reach out for more information about how SitePen can help you with your app development project.