Smart Contracts for Lawyers
Law Aritao
Sun Aug 28 2022

1. The blockchain was first a decentralized ledger (bitcoin). With Ethereum, it is now a ledger and a virtual worldwide computer that saves its state/progress with every block.

2. Smart contracts are self-executing agreements running on the blockchain’s virtual worldwide computer.

3. Lawyers have an important role to play in smart contract design. Read the full post to know more.

Ever had someone fail to hold up their end of an important contract? Remember the grief? Imagine if a contract could also be self-executing, with no intervention required for payment after a service is fulfilled. In 1996, Nick Szabo — a computer scientist and law graduate — authored a paper on this idea.

The smart contract became possible after the first public blockchain- bitcoin — paved the way for other blockchains such as Ethereum. Ethereum evolved blockchain technology to become more than a distributed, decentralized ledger.

With Ethereum, the blockchain became a powerful global computer that can record transactions, execute business logic, and preserve the state (or history) of the network from block to block.

If this sounds alien, please read on. Newcomers to the blockchain are the primary audience I am writing this for.

Start With the Familiar Territory of Obligations: In the blockchain space, lawyers (and law students semester 3 onwards) have an advantage: the lens of obligations.

Nearly everything in law (and the blockchain) revolves around the idea of an obligation- the juridical (and programmatic) necessity to deliver something, perform an action, or refrain from an action.

Consider: Human rights do not just recognize your inherent dignity as a person, they generate obligations to respect and protect your inherent dignity.

Obligations modulate every relationship you will have. Constitutions create obligations that the state must respect (the bill of rights). Those obligations define the parameters between an entire government and a single citizen through a mantle of protection.

Last example: civil law establishes obligations between persons, and contracts can extend and add to those obligations by mutual agreement. These obligations affect our daily relationships and transactions with others.

Let us use the lens of obligations to discuss the blockchain as (1) a decentralized distributed ledger, and (2) an immutable record of a network’s state.

Decentralized: Everyone is Sovereign. Bitcoin introduced the idea of self-sovereignty: everyone is the true owner of their network resources. Everyone is given the power to verify- instead of trust- that a transaction and its sender are authentic. No one — regardless of status- can spend the resources of an account, except the holder of the private key.

A Distributed Ledger: Everyone Knows Everything

Bitcoin introduced the idea of total transparency of transactions. By design, every node in the bitcoin network contains a record of every transaction made- sender, receiver, and amount.

How are transactions initiated, verified, and recorded? By performance of key obligations:

  1. Honor only valid transactions
  2. Record only valid transactions to the blockchain
  3. Reward the participants who secure the blockchain against fraudulent transactions

Transaction Integrity

We are all familiar with the notorious difficulty many Filipinos face when securing a valid ID, since a valid ID is often required to obtain a valid ID. Fortunately, the blockchain does not require this.

With your public-private key pair, you can imprint an indelible, authentic signature on a transaction, while the address functions like a postal address and bank account combined, allowing transactions to be routed properly.

Private Keys: A private key is a 256-bit random number used to sign (encrypt) transactions.

Public Keys: The public key is generated by using one-way cryptography on the private key. By design, it is not possible to calculate a private key from a public key.

Encrypting a message with your private key is an action only you can do. The public key is then used to verify that the message came from you, completing the authentication process.

Addresses: Addresses are 20 characters long, and generated from the public key through hashing.

Transaction Recording: How it Works Each bitcoin block will only accept valid transactions, verified by their receivers, and sent for recording by a special participant called a miner. How are miners assigned?

In bitcoin, record-creation and record security is accomplished by requiring that any new record be written only after a miner solves a mathematical proof-of-work problem.

The proof-of-work problem is a security feature, similar to the combination lock of a vault-but millions of times harder to compute. To better understand it, let us think of Superman and his fortress of solitude.

In one comic, Superman demonstrates that his key to the fortress of solitude is 500,000 tons. The bitcoin proof-of-work puzzle is the mathematical equivalent of requiring a person to lift 500,000 pounds before recording transactions.

What the above means is a bad actor would have to spend millions of dollars just to get a chance to put in something malicious on the chain.

Further, the difficulty of the network puzzle scales with the computing power of all miners combined. Imagine a bad actor bringing in enough power to lift 500,000 tons, only to discover that Superman changed the weight of his key to 1 million tons?

Smart Contracts on Ethereum:

With Ethereum’s virtual computer, the blockchain can now record transactions, run programs, and save the progress and state of those programs.

For example, if the program were running a chess game, the blockchain could save the positions of all the pieces, and even the records previous games played. The computer that runs on the Ethereum network is called the Ethereum Virtual Machine (EVM), and it is in the EVM that the first smart contracts came to life.

Smart Contracts: Business Logic Enforced On the Blockchain

Recall that a smart contract is a self-executing agreement. Smart contracts are able to capture all kinds of business logic from simple (an up front sale) to highly complex (decentralized finance applications for exchanging tokens and staking assets).

Here as well, the lens of obligations is helpful. A smart contract’s entire control flow — and security — depends on a clear design of the obligations between parties.

What Role would lawyers play in smart contracts?

Your onramp is closer than you might think. Before a smart contract can be coded (written in a program language), it must first be designed- and designed well.

Consider: in Q2 2022 alone, over 500 million USD was lost to exploits in smart contracts that could have been prevented by better design.

Therefore, as lawyers, your role in smart contract design is similar to the role you play in legal contract design: Protect your client. Find the loopholes in the terms, and create iron-clad instructions that will result in cleaner, safer code.

Here is a case study where a lawyer could have saved a project a lot of grief and money:

  1. A recent hack involved the use of a flash loan to give a hacker temporary voting power in the form of an 80 percent majority.
  2. The hacker exploited a poorly conceived feature where a 2/3 supermajority could approve any proposal after only 24 hours.
  3. The blockchain equivalent of a hostile takeover occurred after the hacker deposited 1.2 Billion dollars of flash-loaned funds in a special account that awarded voting power based on deposit size, with no pre-requisite deposit length.
  4. Sidebar: A flash loan is a unique blockchain feature where you can borrow funds with no collateral, provided they are returned in the same transaction with a fee.
  5. The hacker used their supermajority to approve their own malicious proposal.
  6. Upon expiry of the wait time, the hacker proceeded to strip the project of all its resources.
  7. The hacker’s net profit was USD 80 million after paying the interest on the flash loan.

How could a lawyer with smart contract knowledge have prevented this? By reviewing the business logic of the project, and advising the team to secure against hostile takeover mechanisms.

What we have learned:

  1. The blockchain is a decentralized ledger and also a virtual worldwide computer that saves its state/progress with every block.
  2. Smart contracts are self-executing programs running on the blockchain’s virtual worldwide computer.
  3. Lawyers have an important role to play in smart contract design.