Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"Smart Contracts" - Key Concepts and Examples

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

"Smart Contracts" - Key Concepts and Examples

Blockchain, Cryptocurrency + Law
Chicago-Kent College of Law, Illinois Institute of Technology
March 26, 2018
Guest Lecture by @mjbommar

Avatar for Michael Bommarito

Michael Bommarito PRO

March 26, 2018
Tweet

More Decks by Michael Bommarito

Other Decks in Technology

Transcript

  1. “Smart” Contracts Key Concepts and Examples Blockchain, Cryptocurrency + Law

    Chicago-Kent College of Law, Illinois Institute of Technology March 26, 2018 Guest Lecture by @mjbommar
  2. AGENDA 1. What is a “smart” contract? 2. Why is

    blockchain or DLT relevant? 3. Who executes a smart contract?
  3. AGENDA 1. What is a “smart” contract? 2. Why is

    blockchain or DLT relevant? 3. Who executes a smart contract? 4. How do you write a smart contract?
  4. AGENDA 1. What is a “smart” contract? 2. Why is

    blockchain or DLT relevant? 3. Who executes a smart contract? 4. How do you write a smart contract? 5. What does a smart contract actually look like?
  5. HISTORY Sources: Szabo, First Monday • Rewrite #1: http://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/smart_contracts_2.html •

    Rewrite #2: http://ojphi.org/ojs/index.php/fm/article/view/548/469 The basic idea of smart contracts is that many kinds of contractual clauses (such as liens, bonding, delineation of property rights, etc.) can be embedded in the hardware and software we deal with, in such a way as to make breach of contract expensive (if desired, sometimes prohibitively so) for the breacher.
  6. HISTORY Sources: Szabo, First Monday • Rewrite #1: http://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/smart_contracts_2.html •

    Rewrite #2: http://ojphi.org/ojs/index.php/fm/article/view/548/469 Most Common Synonyms: Self-executing contracts Digital contracts Blockchain contracts Ethereum contracts
  7. CONCEPT 1. Purchaser sends item code to contract by typing

    item number. 2. Contract returns item price and requests Purchaser remit this amount. 3. Purchaser remits funds. 4. Contract validates funds. 5. Contract retrieves item and delivers to Purchaser. (varies by machine age/type)
  8. CONCEPT Examples • Mechanical arm jams or misses item •

    Mechanical arm picks wrong item • Swing door is stuck and item not accessible • Coinbox is full and no additional funds can be deposited • Purchaser does not have exact change • Purchaser does not have valid currency (tokens, Euros) • Purchaser remits purposefully counterfeit funds • Purchaser physically removes items by breaking glass • Purchaser physically removes deposited funds by opening coinbox • Price data is incorrect but physical access is required to update vending machine (1000% sugar price spike)
  9. CONCEPT Example Business Issue Analysis • I own 100 vending

    machines. • I have to make an (un)expected payment on a debt instrument, insurance policy, etc. • I have the funds available inside the machines, but have to collect them from 100 separate locations and then redeposit. • It costs time/money to visit and access 100 machines. • Subsequently, those machines now don’t have funds on hand to make change. • Instead, you might take a short-term loan secured against the funds/machines to pay the former debt instrument.
  10. CONCEPT What do we do if something does go wrong?

    Who do you sue? Tenant? Premises owner? Vending machine lessor? Vending machine manufacturer? Vending machine software developer?
  11. CONCEPT What do we do if something does go wrong?

    Imagine you represent the Purchaser. What evidence do you demand?
  12. CONCEPT What do we do if something does go wrong?

    Imagine you represent the Vending Machine. What evidence do you demand?
  13. CONCEPT What do we do if something does go wrong?

    Imagine you represent a third party with a contingent claim. What evidence do you demand? (think state treasury, tenant, lessor)
  14. ASIDE What do we do if something does go wrong?

    Internet of Things. Sensor data. Oracles.
  15. CONCEPT What do we do if something does go wrong?

    KEY: Dispute resolution can be complex in real life too. Smart contracts just forces us to explicitly address it!
  16. PROMPT Smart contracts already exist. We are already using them.

    Why do we need blockchains or distributed ledgers?
  17. PROMPT Pro Clear Interaction Protocol: Contract has explicit interaction instructions.

    Send me one number. Send me two strings. More to come later on this.
  18. PROMPT Pro Open Evidence: In the event of a dispute,

    evidence can part of open audit trail. No information asymmetry. Reduce discovery and civil procedure process.
  19. PROMPT Pro Better Funds Management: Both parties can use funds

    available, not just funds-on-hand. Funds are (very) divisible. No more exact change problem. Funds can move (much) faster.
  20. PROMPT Con Adoption: Today, blockchain and DLT are not sufficiently

    adopted. (consumer adoption not required. Think AmEx.)
  21. PROMPT Con Flexibility: The ambiguity and flexibility in our current

    legal system is a double-edged sword with many benefits. (prompt: if this “feature” of status quo systematically favors larger, more sophisticated parties, is there a normative justification?)
  22. SOLUTION But how do we trust the many devices? Incentivize

    the devices to run the contract instructions.
  23. SOLUTION But how do we trust the many devices? Incentivize

    the devices to run the contract instructions. Incentivize the device to report the computation results accurately.
  24. SOLUTION But how do we trust the many devices? Incentivize

    the devices to run the contract instructions. Incentivize the device to report the computation results accurately. Incentivize the devices to report the computation results quickly.
  25. SOLUTION And in reverse, how does the device trust the

    contract? (see cost and instruction set models for Ethereum, EOS, Cardano, etc.)
  26. SOLUTION While general classes of incentives are similar, the details

    may reasonably vary from system to system. Many systems are open source. Private chains can be created with “custom” incentives. Example: • Private Bitcoin/Ethereum networks with different block rewards, gas costs, instruction sets
  27. PROCESS 1. Design or model contract incentives 2. Examine ability/cost

    of various DLT systems/programming languages to implement incentives 3. Select language to write contract 4. Implement test cases for contract based on incentives 5. Implement contract methods 6. Validate contract methods against test cases 7. Deploy contract on DLT system
  28. PROCESS Step 2 Choose a DLT/blockchain technology. Which fits your

    use case best? Which is easiest to use? Which makes sense for your target market/audience?
  29. PROCESS Step 3 Select a language to write your contract

    in. Each DLT/chain has its own languages. Example: Ethereum has Serpent, Solidity, Viper.
  30. PROCESS Step 4 Implement test cases in code for contract

    based on Step 1. If a right exists for an actor, test that party can actually do it. If an obligation exists for an actor, test that it is met. If a condition generates a penalty or reward, make sure it happens.
  31. PROCESS ASIDE “Software is eating the world.” If writing contracts

    is becoming more like writing software, then we should acknowledge that there are different philosophies of software development. Some are compatible, others are not. Examples: Test-Driven Development (TDD), Agile, Pair Programming, Formal Verification, Functional, Procedural
  32. PROCESS Step 5 Implement contract code based on Step 1.

    Details vary widely between DLT/chain and language. Generally working within private or public test network.
  33. PROCESS Step 6 Validate contract methods from Step 5 against

    test cases from Step 4. Make sure 100% of your contract has test cases that pass. Is it malpractice to have less than 100% contract coverage and pass rate? What about modeling a traditional contract? Measurement drives change...
  34. PROCESS Step 7 Deploy contract on DLT system. Varies widely

    between DLT/chain. Publishing on Ethereum network is a cheap transaction. Publishing on NEO network is not a cheap transaction.
  35. DIFFERENCES Open Source Unlike the drafters of traditional contracts, the

    crypto community embraces open source. You can find the source code to almost every major project - hundreds of millions of dollars of labor and investment - freely available on GitHub.
  36. DIFFERENCES Re-use One of the greatest benefits of open source

    is that “modular” or “re-usable” components are developed in large numbers. You are not probably not the first person to need a wheel. Nor will your wheel be the best. Don’t design and build one yourself. Just import it.
  37. HOW TO GET STARTED Recommendation: While there are other options,

    the Ethereum community has the best documented and most supported technology. Start by learning it.
  38. HOW TO GET STARTED Recommendation: Start by using Remix, a

    browser-based development environment. Zero downloads or setup on any device, even a phone or tablet. URL: http://remix.ethereum.org/
  39. HOW TO GET STARTED Recommendation: Skim the first sections of

    Documentation from Ethereum Solidity team. Get an idea of the big picture. Documentation: http://solidity.readthedocs.io/en/v0.4.21/index.html# Examples: • http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html • http://solidity.readthedocs.io/en/v0.4.21/solidity-by-example.html#voting
  40. HOW TO GET STARTED Recommendation: Watch “willitscale” videos on YouTube

    with corresponding GitHub code. Videos: https://www.youtube.com/channel/UCaWes1eWQ9TbzA695gl_PtA/videos Code: https://github.com/willitscale/learning-solidity
  41. ROLL UP YOUR SLEEVES 1. Hello World a. Store a

    single number (integer). b. Adapt the contract to store a string. 2. Remix IDE Deep Dive 3. Voting Example 4. willitscale Series