Making Sense of Blockchain Smart Contracts

04 June 2016 | on smart-contracts

house rental contract, Mesopotamia, 514 BC - http://www.metmuseum.org/art/collection/search/321732

House rental contract, Mesopotamia, 514 BC

Note to reader: This article also appeared on Coindesk on June 4, 2016. In this piece I argue for a distinction between "smart contract code" and "smart legal contracts". This piece has since been cited by R3's Tim Swanson & Lee Braine's work at Barclays.

The term “smart contract” has no clear and settled definition.The idea has long been hyped to the public as a central component of next-generation blockchain platforms, and as a key capability for any practical enterprise application.

They are defined variously as “autonomous machines”, “contracts between parties stored on a blockchain” or “any computation that takes place on a blockchain”. Many debates about the nature of smart contracts are really just contests between competing terminology.

The different definitions usually fall into one of two categories. Sometimes the term is used to identify a specific technology – code that is stored, verified and executed on a blockchain. Let’s call this type of definition “smart contract code”.

Other times, the term is used to refer to a specific application of that technology: as a complement, or substitute, for legal contracts. Let’s name these “smart legal contracts”.

Using the same term to refer to distinct concepts makes answering even simple questions impossible. For instance, one question I’m often asked is simply: what are the capabilities of a smart contract?

If we are talking about smart contract code, then the answer depends on the capabilities of the language used to express the contract and the technical features of the blockchain on which it operates.

But if we are asking about using that technology to create a binding legal agreement, or an effective substitute for a binding legal agreement, the answer depends on far more than the technology. This answer depends on existing legal doctrine and how our legal, political and commercial institutions decide to treat the technology. If businesspeople don’t trust it, the legislature doesn’t recognize it and the courts can’t interpret it, then it won’t be a very practically useful “contract”.

It would be futile to try and change the way people use the term already. Practically speaking, we are probably stuck using – or at least reading – the term “smart contract” for now. This makes it essential for anyone interested in this space to understand the different ways the term is used and be able to distinguish clearly between them.

Smart contracts as smart contract code

Blockchains can run code. While the first blockchains were designed to perform a small set of simple operations – mainly, transactions of a currency-like token – techniques have been developed to allow blockchains to perform more complex operations, defined in full-fledged programming languages.

Because these programs are run on a blockchain, they have unique characteristics compared to other types of software. First, the program itself is recorded on the blockchain, which gives it a blockchain’s characteristic permanence and censorship resistance. Second, the program can itself control blockchain assets – i.e., it can store and transfer amounts of cryptocurrency. Third, the program is executed by the blockchain, meaning it will always execute as written and no one can interfere with its operation.

To developers and others working directly with blockchain technology, the term “smart contracts” is most often used to refer to this blockchain code. You’ll see this use of the term in the Ethereum documentation, on stackexchange and in technically minded articles. The term has been particularly associated with the Ethereum project, whose primary purpose is to be a platform for smart contract code. But today, the term is used generically across the community to refer to any complex program that is stored and executed on a blockchain.

Calling these programs contracts is helpful in that this code is governing something important or valuable. We only go to the trouble of creating a binding contract when it’s important that we be able to enforce the terms. Similarly, we only use smart contract code when the code controls something important, like money or identity.

That said, smart contract code need not resemble anything we would ordinarily think of as a “contract”. While the code could articulate a conditional financial transaction (“send 1 BTC from Alice to Bob on July 1, 2016”), it could also be a governance application that controls account permissions (“if Alice has voted yes, remove Bob’s voting rights over Application X and notify the following accounts…”).

In many cases, smart contract code is not used in isolation but as a small piece in a larger application. Every DApp, DAO, or other blockchain-based application is built using smart contract code to perform operations on their chosen blockchain. Any Ethereum application that you’ve read about – like Augur, Slock.it, or Boardroom – is made out of smart contract code.

Imperfect, misleading, and someday outdated

The term receives a lot of valid criticism. Relying on the metaphor of a “contract” is misleading because it emphasizes a single narrow use case. The term fails to capture one of the key capabilities of blockchain programs: that they have a kind of independent agency.

Smart contract programs can themselves hold balances of cryptocurrency, or even control other smart contract programs. Once they are created, they can act autonomously when called to perform an action. For this reason, many prefer the term “smart agent”, analogous to the more general concept of a software agent.

Eventually, this use of the term may simply fade from use as blockchain technology matures.

Developers will be more likely to refer to a specific language (“Let’s look at your Solidity code”) or platform (“Our application runs on Eris.db”) that they are working with, as opposed to a generic term that could describe any complex operation on a blockchain.

The capabilities and purpose of smart contract code as distinct from other code may simply become clear from context, without requiring the use of a clumsy analogy like “contract”. It might end up being more similar to how we speak of HTML and JavaScript today, without having to think about how the former is a “markup” language, playing a distinct role from JavaScript in the overall web application.

Smart contracts as smart legal contracts

Among those who work in finance or law, the term “smart contract” is often read quite differently than the definition above.

“Smart contract” here refers to a specific use case of smart-contract code – a way of using blockchain technology to complement, or replace, existing legal contracts. This is the definition of the term I considered in my last post: the use of code to articulate, verify, and enforce an agreement between parties. A smart legal contract.

These smart legal contracts would most likely be a combination of smart contract code and more traditional legal language. For instance, imagine a supplier of goods enters into a smart legal contract with a retailer. The payment terms could be defined in code and executed automatically when delivery is made. But the retailer would likely insist the contract include an indemnity clause, whereby the supplier agrees to indemnify the retailer against claims flowing from a defective product. There would be no point representing this clause in code, since it is not something that can self-execute – it exists to be interpreted and enforced by a court in the case of litigation.

Commercial agreements are full of boilerplate clauses that protect parties from various edge-case liabilities, and these are not always suitable for representation and execution through code, meaning that smart legal contracts will require (at least for the foreseeable future) a blend between code and natural language. This is the basic idea behind Eris Industries’ dual integration system, Primavera de Fillipi’s proposed Legal Framework for Crypto-Ledger Transactions, and R3’s Corda smart contracts system.

Could smart legal contracts ever be considered legally enforceable? Probably. Despite what many think, the conditions under which an agreement becomes a legally enforceable contract are flexible and attuned to the underlying relationship between the parties, rather than dependent on the form the contract takes. Anything from a verbal agreement to an email conversation can become a contract at law, if the basic elements of a contract can be found.

Many contracts, many use cases

The category of smart legal contracts is complicated by the fact that there are many different types of contracts in the world, only some of which are obvious candidates for use as “smart contracts”. A legal contract could be anything from a verbal agreement for someone to paint your house to a derivative traded electronically in financial markets.

Since early 2015, the use cases attracting the most attention are smart legal contracts as smart financial instruments like shares, bonds, or derivatives contracts. Articulating these contracts in code could allow financial markets to become more automated and simplify many process-intensive systems related to trading and servicing of financial instruments.

These “smart financial instruments” do not exist at scale today, although many people are working to build them. R3’s recently announced Corda platform is designed to facilitate this type of smart-contract. Digital Asset Holdings recently acqui-hired Elevance, a Swiss firm that has developed a way to model financial agreements in code. In April, Barclays’ revealed details of a scheme, in cooperation with R3, to represent ISDA agreements in smart contract code.

Financial instruments are just one type of contract that could benefit from blockchain code. As the technology matures, other assets – e.g. real estate, or intellectual property – may be stored and traded over blockchain systems. As new asset types go “on-chain”, the agreements used to govern those assets in the world today (like a mortgage or licensing agreement) may benefit from blockchain-based analogs.

Alternatives to traditional legal agreements

Many advocates for blockchain technology see larger possibilities. Rather than merely imitate or complement the legal contracts we use today, perhaps smart contract code could be used to facilitate new types of commercial arrangements.

We might even call this a third definition of the term: using smart contract code to create novel, alternative forms of agreements that are nonetheless commercially useful. Let's call these "smart alternative contracts".

This approach takes a broader view of the real-world problem solved by contracts. Commerce depends on individuals being able to form stable, predictable agreements with one another. Contracts, along with a strong legal system, are the primary mechanisms we use to shape each party’s incentives to the point where they have sufficient confidence in their relationship to engage in the risky business of trade.

But perhaps legal agreements are not the only solution to this general problem. Smart contract code offers a new set of tools to articulate and enforce terms, and they can be used to create systems of incentives that may be sufficient to make commercial relationships possible.

The most widely discussed opportunity of this type is machine-to-machine commerce. The growing ecosystem of smart devices – particularly those that are in some fashion autonomous – will eventually need a way to engage in basic commercial interactions with one another. For instance, a washer that buys its own detergent or a car that can pay to recharge itself.

These transactions still require a minimum level of trust to be commercially viable, but are ill-suited for legal contracts, which are comparatively expensive and require the involvement of legal persons like a corporation or human. Smart alternative contracts might enable an entirely new type of commerce carried out between our computers, cars, phones, and appliances.

There probably are – or will be – other types of commercial interaction that aren’t well suited to traditional legal contracts. New markets, suddenly made possible by technology, but which are underserved by legal tools that are slow to innovate and adapt. Smart alternative contracts might let us stretch the web of trust out a little further, a little faster, beyond the reach of the legal system, where they can enable new forms of commerce not possible today.

Conclusion

The lack of clear terminology in this field is an unfortunate reality. Those of us who work in the blockchain space should be mindful of how the term is being used in different communities, and be prepared to ask a series of annoying, though necessary, clarifying questions when asked about the nature and potential of “smart contracts”.

The different uses of the term illustrate a broader challenge in our industry. The interdisciplinary nature of blockchain technology, and “smart contracts” in particular, lead people to see the technology as primarily belonging to their own discipline, at the expense of the others.

Lawyers often look at smart contracts and see marginally improved legal agreements, without appreciating the fuller potential of blockchain-code to extend beyond law’s reach. Developers, on the other hand, consider smart contracts and see the limitless possibilities of software, without appreciating the subtleties and commercial realities reflected in traditional legal agreements.

As with any interdisciplinary field, both must learn from the other.

How Close Are Smart Contracts to Impacting Real-World Law?

11 April 2016 | on smart-contracts, ethereum

Note to reader: This article also appeared on Coindesk on April 11, 2016. In this piece I introduce the basic concept of a smart contract and explain why blockchains are an ideal technology to implement them.

Over the last year, the concept of a "smart contract" has received renewed attention in legal and business circles.

Advancements in blockchain technology have led some to believe that smart contracts could soon offer alternatives to traditional commercial and financial agreements, with dire results for the legal and financial sectors. While this enthusiasm may be premature, the legal profession nonetheless remains mostly unaware of this important emerging technology and the long-term implications for their profession.

In this context, "smart contract" refers specifically to the use of computer code to articulate, verify and execute an agreement between parties. Whereas a typical contract is drafted using natural language, the terms of smart contracts are expressed in code, similar to a programming language like javascript or HTML.

The contract is then "executed" by a computer – given the conditions of the agreement, and a set of defined inputs, the smart contract enforces its own terms.

Readers familiar with blockchain technology will know that the term "smart contract" is often used in a more general sense to refer to any script or program that operates on a blockchain. However for the purposes of this article, we focus on the narrower meaning described above: using code in place of traditional contractual agreements between parties.

Point of origin

The term "smart contract" was first popularized by computer scientist Nick Szabo in his 1997 paper "The Idea of Smart Contracts". The vending machine, he described, is the simplest form of a "smart contract" – a mechanical device designed to transfer ownership of a good (a candy bar) when provided with a certain defined input ($1.50). Because the machine itself "controls" the property – by being physically sealed – it is able to enforce the terms of the "contract".

Extending the concept, Szabo suggested that computer code could be used in place of mechanical devices to facilitate far more complex transactions of digital property. Rather than transfer ownership of a candy bar, a smart contract could transfer ownership of real estate, shares or intellectual property. The program would define what "inputs" were necessary for the contract to execute – things like payment, votes of board members or any other condition that can be expressed by code.

Consider a basic options contract. A call options contract entitles the holder to buy a given security at a defined price. In our example, Alice buys our "smart options contract" from Bob. The contract entitles Alice to purchase 100 shares of Acme Inc from Bob at a defined price of $50 per share. The contract has an expiry date, after which Alice is no longer entitled to buy the share at the defined "strike price".

Expressed in pseudo-code, a simple "smart options contract" might look like this:

contract Option  
  strikePrice = $50
  holder = Alice
  seller = Bob
  asset = 100 shares of Acme Inc.
  expiryDate = June 1st, 2016

function exercise ( ) {  
  If Message Sender = holder, and
  If Current Date < expiryDate, then
    holder send($5,000) to seller, and
    seller send(asset) to holder
  }

In the first section, the smart options contract defines the relevant terms – the underlying asset, the strike price, the identities of each party and the expiry date. Then, a function we’ve named "exercise" enables the holder to trigger the purchase of shares at the strike price at any moment before the expiry date.

The function first checks to see if the entity triggering it (the "Message Sender") is the holder, and then checks to see that the contract is still within the expiry date.

If both are true, then the contract immediately executes by transferring cash from the holder to the seller, and the assets from the seller to the holder, according to the contract’s terms.

Two challenges

Until recently, smart contracts were little more than theory. In general, there were two fundamental challenges that needed to be addressed before smart contracts could be used in the real world.

First: How would a smart contract actually control real assets so that it could enforce an agreement? A vending machine, to return to Szabo's example, controls property by physically securing it inside of itself. But how could code do the same? In our options contract above, the "exercise" function transfers money and assets between the two parties. How can a computer program control real-world assets like cash and shares?

Second: What computer would be trusted to "execute" those terms in a way that both parties could rely upon? Parties must not only agree on the code of their contract, but also the computer which interprets and executes that code. A shared standard, at the minimum, would have to exist, and be used in a way that was verifiable by each party – ideally, without requiring the parties to physically inspect the computer in question.

In the last few years, solutions to both of these problems have come into sight. Emerging research and development surrounding blockchain technology may provide a basis to make smart contracts a reality in the near future.

The first use of blockchain technology was the digital currency bitcoin, made famous by its mysterious creator and sudden price increase in late 2013. In the last few years, its underlying "blockchain" has been intensely studied and adapted to expand its use beyond simple digital currencies. Startups, open-source communities and large financial institutions alike are improving and expanding the technology with the aim of one day using it to facilitate exchange of fully digital assets.

A blockchain is an authoritative database. It is a database that, by virtue of the way it is maintained and updated, has very high trust properties. Blockchains are not controlled by a single party. There is no single company, organization or person that has ultimate control over a blockchain. Rather, a blockchain is maintained, updated, and secured by a network of participating computers. Each computer keeps a full copy of the blockchain database, and each copy is kept in synchronization with the others by a system of cryptographically-enforced rules called a consensus algorithm.

Crucially, blockchains are append-only databases, meaning that once information is validly added, it can never be removed. Each update to the blockchain is secured by a cryptographic process known as a hash function, which allows the network to detect and reject any attempt to distribute an edited copy of the database. In this way, blockchains form the foundation for the recording and transfer of fully digital assets.

Because the blockchain is always kept in synchronization, there is only ever one true record of ownership – essential to prevent anyone trying to double-spend their assets by sending it to multiple parties at the same time, a problem that plagued previous attempts to create digital assets. Because it is impossible to edit a blockchain once it has been properly updated, parties have mathematically-enforced confidence that the record of their ownership will persist into the future.

Emerging solutions

While the technology is still in early stages, many now believe that if blockchains can create a secure platform for the trade of digital assets, they may also solve the two fundamental challenges facing smart contracts.

First, smart contracts require a way for computer code to control real assets. By enabling fully digitized assets, blockchains make it possible for code to exercise control over property. On a blockchain, control over an asset means controlling a cryptographic key that corresponds to the asset in question, rather than any physical object.

Thus in our example above, the options contract could itself have control of the underlying assets, rather than an escrow agent. When the "exercise" function is called, the operation of the code would transfer the assets without requiring any human assistance.

Second, smart contracts need a "trusted computer" that would execute the terms of the contract. This is the blockchain itself. The blockchains that are being developed today are not only databases, but distributed computers that can execute code as well as record ownership of assets.

Our “smart option” example would itself be uploaded and stored on a blockchain, and would be executed by the blockchain when instructed to do so.

The same properties that make blockchains ideal to record ownership of assets also make them ideal for executing smart contracts. Once the code of the contract is uploaded and recorded onto the blockchain, the parties can have confidence that the contract cannot be altered, and that it will perform as expected.

Current work

Blockchain smart contracts may not be as far away as we expect. Banks, exchanges, and other financial institutions are actively developing blockchain technologies that will enable them to store and trade real assets over blockchain systems. Nasdaq, in partnership with blockchain startup Chain, has developed and begun testing a private-market equity trading platform.

A next-generation open-source blockchain called Ethereum aims to be the foundation for a new industry of non-traditional decentralized commerce. A consortium of 43 banks, working with blockchain firm R3, have begun work on a shared industry platform based on blockchain technology specifically designed to facilitate financial agreements. Within a few years, financial markets may be trading fully-digital assets across blockchain networks, with the terms of those trades enforced by code.

The impact will not be limited to financial contracts, although these are the most obvious use cases. As techniques are developed that enable other types of property to be recorded and transacted on a blockchain, the possible applications for smart contracts will multiply.

If they ever become widely used, smart contracts could alter the nature of corporate and commercial transactions. The advantages of software that have revolutionized so many industries – automation, predictability and speed – could finally be brought to bear on segments of the legal industry.

Representing contractual terms in code, rather than natural language, could bring clarity and predictability to agreements. A smart contract could be tested against any set of inputs – in other words, against any set of material facts which it takes as inputs - allowing lawyers on either side of a deal to know precisely how the contract would execute in every computationally-possible outcome.

In our simple Smart Option example above, each of Alice and Bob could "dry run" the contract in a simulated environment, where every possible input is tested. While this is unnecessary in such a simple example, imagine a contract with thousands of inputs, and hundreds of nested if-then statements – as is common in many complex financial agreements.

These, too, could be tested against every possible input defined in the code. Analogous to how software developers “debug” their own code by testing it in every possible circumstance, lawyers could test contracts, giving each side of a deal a clearer understanding of their risk – and perhaps requiring fewer billable hours.

Alternatives, not replacement

Of course, smart contracts will never fully replace natural-language law. Many types of agreements can never be fully expressed in code or executed by a computer – for instance, those that involve human performance rather than the exchange of dematerialized assets.

Even fully self-executing contracts will ultimately need to make reference to legal terms and concepts that will define each party’s rights if their relationship leads to litigation. Rather, the emergence of smart contracts will lead to a re-evaluation of common practice, as lawyers and clients alike discover which types of agreements and terms are best suited to code, which should be left to natural language, and how to combine each to achieve the best of both worlds.

For now, smart contracts are still science fiction. But for the first time we have a technology that could be used to bring them into commercial use. While that day may still be years away, legal professionals would be wise to consider how these innovations could impact their business.