Uploaded by Cristh Tejada

CP108 COURSE OUTLINE (4)

advertisement
ACADEMIC YEAR 2021/2022
CP108 HASKELLPLUTUS
4 ECTS
ERNEST MUSYOKI
COURSE DESCRIPTION
Students will develop their functional programming skills in the languages Haskell and
Plutus. This will help make them competent smart contract programmers; adept at changing
the world through the creation of new systems and decentralised applications in the Cardano
Ecosystem. The course opens a door of opportunity to work in the early development of
Cardano; the fastest growing Cryptocurrency. Which aims to bank the unbanked and create
new financial systems for emerging world markets.
The course will teach you the core principles of how to code in both Haskell and Plutus.
Modules will cover the building blocks of Haskell and Plutus, including functions and data
types, type classes, monads, template Haskell, using the Plutus Playground, The Marlowe
Playground, the Extended UTXO model, working with Plutus on and off the chain, minting
policies, state machines, the Plutus application framework, as well as case studies and
practical exercises.
Prerequisites: While you do not need to be an expert in formal methods, programming
experience and a general aptitude for logical and mathematical thinking are highly desirable.
COURSE OBJECTIVES
●
●
●
To gain an understanding of functional programming in Plutus.
To understand the transformative power of blockchain technology
To develop competent smart contract developers
COURSE OUTCOMES
●
Theoretical introduction to Cryptocurrency, Blockchain, and Cardano.
●
Develop an understanding of the invention of decentralized consensus through
proof-of-work, and the difference between proof-of-work and proof-of-stake.
●
Technical overview of Functional Programming Haskell and Plutus.
1
ACADEMIC YEAR 2021/2022
●
Practical introduction to functions and data types, type classes, monads, template
Haskell, using the Plutus Playground, The Marlowe Playground, the Extended UTXO
model, working with Plutus on and off the chain, minting policies, state machines, the
Plutus application framework in case studies and practical exercises.
COURSE CONTENT
UNIT /SESSION 1: INTRODUCTION TO CRYPTOGRAPHY BLOCKCHAIN 27TH SEPTEMBER - 3RD OCTOBER
●
●
●
●
History of Cryptography
Introduction to Blockchain
Object Oriented Programming vs Functional Programming
Smart Contracts
This introductory module will develop your conceptual understanding of Cryptography, Blockchain and
its role as a disruptor. You will review the historical role of decentralized infrastructures with particular
focus on original intent. The course will lead to the present day and an exploration of the operational
nature of the technology. By examining underlying blockchain protocols, students will learn to evaluate
blockchain based solutions. Students will develop an appreciation and understanding of how to apply
their knowledge through Functional Programming and smart contracts.a total grasp of the
interoperability that has driven the interest and adoption of cryptocurrencies and blockchain in
business and government. This will be realized with a deep understanding of smart contracts and their
role in the emergence of decentralized applications.
Learning outcome
●
●
●
Theoretical introduction to digital currencies and their history
Develop an understanding of the invention of decentralized consensus through proof-of-work
and the difference between proof-of-work and proof-of-stake
Technical overview of cryptographic currencies such as Cardano, as well as smart contracts
FORUM AND ASSIGNMENTS
●
●
●
Read the Original Cardano Whitepaper
Participate in the discussion Forum Questions.
Complete the quiz.
https://why.cardano.org/
UNIT /SESSION 2: Intro to Functional Programming: Haskell
●
●
●
4TH OCTOBER - 10TH OCTOBER
GHC Compiler
Types and Type classes
Functions and High order Functions
Haskell is a functional programming language, named after mathematician Haskell Brooks Curry, who
made important contributions to mathematical logic that were used as the basis for functional
2
ACADEMIC YEAR 2021/2022
programming.This module aims at providing the students with the basics of haskell for a smooth
transition into Plutus the native smart contract language for the Cardano blockchain.
Learning outcome
By the end of this module the students will be able to:
●
●
●
●
Master the basics of writing Haskell scripts
Distinguish the different Haskell data types
Learn core Haskell scripting elements such as variables and flow control structures
Write Simple Haskell functions to facilitate code reuse
FORUM AND ASSIGNMENTS
●
●
●
Complete the assignment replit: https://replit.com/
Participate in the discussion Forum Questions.
Complete the quiz.
UNIT /SESSION 3: THE (E)UTxO-model
11TH OCTOBER - 17TH OCTOBER
One of the most important things you need to understand in order to write Plutus smart contracts is
the accounting model that Cardano uses, the Extended Unspent Transaction Output model. This is
different and less intuitive than the Ethereum method for creating smart contracts. It has a lot of
advantages, but it requires a new way of thinking about smart contracts.
●
●
●
●
●
The (E)UTxO-model.
Building the example code.
An auction contract in the EUTxO-model.
A brief look at the auction code.
Running an example auction contract on a local Playground.
FORUM AND ASSIGNMENTS
●
●
●
Complete the assignment at the Plutus Playground. https://playground.plutus.iohkdev.io/
Participate in the discussion Forum Questions.
Complete the quiz.
UNIT /SESSION 4: VALIDATION
18TH OCTOBER - 24TH OCTOBER
In this lecture we cover low-level, untyped on-chain validation scripts and high-level, typed on-chain
validation scripts. Validation allows nodes to validate a given transaction and whether it is allowed to
consume a given UTxO.
●
●
●
Triggering change.
Low-level, untyped on-chain validation scripts.
High-level, typed on-chain validation scripts.
3
ACADEMIC YEAR 2021/2022
FORUM AND ASSIGNMENTS
Which forums and assignments are due for this first week/session
●
●
●
Complete the assignment at the Plutus Playground. https://playground.plutus.iohkdev.io/
Participate in the discussion Forum Questions.
Complete the quiz.
UNIT /SESSION 5: SCRIPT CONTEXTS
25TH OCTOBER - 31ST OCTOBER
When we explained the (E)UTxO model in the first lecture, we mentioned that in order to unlock a
script address, the script attached to the address is run, and that script gets three pieces of
information - the datum, the redeemer and the context. in this lecture we will start looking at the
context.
●
●
●
●
Script contexts.
Handling time.
A vesting example.
Parameterized contracts.
FORUM AND ASSIGNMENTS
Which forums and assignments are due for this first week/session
●
●
●
Complete the assignment at the Plutus Playground. https://playground.plutus.iohkdev.io/
Participate in the discussion Forum Questions.
Complete the quiz.
UNIT /SESSION 6: MONADS
1ST NOVEMBER - 7TH NOVEMBER
The on-chain part takes care of validation but, in order for there to be something to be validated, we
must build a transaction and submit it to the blockchain. And, that is what the off-chain part does.So,
in this Lecture, we will start talking about how to write off-chain Plutus code. All the off-chain code (the
wallet code), is written in a special monad - the Contract Monad.
●
●
●
Monads.
The EmulatorTrace-monad.
The Contract-monad.
FORUM AND ASSIGNMENTS
Which forums and assignments are due for this week/session
●
●
●
Complete the assignment at the Plutus Playground. https://playground.plutus.iohkdev.io/
Participate in the discussion Forum Questions.
Complete the quiz.
UNIT /SESSION 7: TOKENS
8TH NOVEMBER - 14 NOVEMBER
We are going to talk about how Plutus supports native tokens and how to define under which
conditions native tokens can be minted and burned. But before we get to that, let’s explore what value
means in Cardano.
4
ACADEMIC YEAR 2021/2022
●
●
●
●
Values.
Native Tokens.
Minting Policy
Non Fungible Tokens
FORUM AND ASSIGNMENTS
Which forums and assignments are due for this week/session
●
●
●
Complete the assignment at the Plutus Playground. https://playground.plutus.iohkdev.io/
Participate in the discussion Forum Questions.
Complete the quiz.
UNIT /SESSION 8: ORACLES
15TH NOVEMBER - 21ST NOVEMBER
In the blockchain world, an oracle is a way to get real-world information onto the blockchain, in order
to make it usable in smart contracts. In this lecture we are going to look at a case study, to see how
what we have learned so far can be turned into an actual application. A collection of executables that
even come with a little front end. It will be a real dApp, apart from the fact that we don’t have a real
blockchain available yet. This will run on the Alonzo testnet. The example we are going to use for this
is to implement a very simple oracle.
●
●
●
●
●
Oracles.
The Core module.
The Swap module.
The Funds module.
The Test module.
FORUM AND ASSIGNMENTS
●
●
Complete the assignment on the Alonzo testnet
Participate in the discussion Forum Questions.
UNIT /SESSION 9: PLUTUS APPLICATION BACKEND
22ND NOVEMBER - 28TH NOVEMBER
But now we will talk about something new - the Plutus Application Backend (PAB), which allows us to
take all the stuff we have done and turn it into an executable that runs the contracts.
●
●
Using the PAB.
Commit schemes.
FORUM AND ASSIGNMENTS
Which forums and assignments are due for this week/session
●
●
Complete the assignment at the Plutus Playground. https://playground.plutus.iohkdev.io/
Participate in the discussion Forum Questions
UNIT /SESSION 10: STATE MACHINES
29TH NOVEMBER - 5TH DECEMBER
5
ACADEMIC YEAR 2021/2022
In this lecture we will look at state machines. State machines can be very useful for writing shorter
and more concise contracts, both on and off-chain. There is higher level support for state machines in
the Plutus libraries that builds on top of the lower level mechanisms we have seen so far.
●
●
●
●
●
●
State machines.
State machine example: token sale.
Automatic testing using emulator traces.
Optics.
Property based testing with QuickCheck.
Testing Plutus contracts with property based testing.
FORUM AND ASSIGNMENTS
Which forums and assignments are due for this week/session
●
●
Complete the assignment on the Plutus
Participate in the discussion Forum Questions.
UNIT /SESSION 11: MARLOWE
6TH DECEMBER - 12TH DECEMBER
Marlowe is a special-purpose language for financial contracts on Cardano, allowing contracts to be
written in the language of finance, rather than using a general-purpose language on the blockchain.
Because it is special-purpose, it is easy to read, write and understand.
●
●
●
Marlowe overview.
Marlowe in Plutus.
Marlowe Playground demo
FORUM AND ASSIGNMENTS
●
●
Complete the assignment at the Marlowe Playground. https://alpha.marlowe.iohkdev.io/#/
Participate in the discussion Forum Questions.
UNIT /SESSION 12: UNISWAP
3RD JANUARY - 9TH JANUARY
Uniswap is a decentralized finance application that allows swapping of tokens without any central
authority. Students will learn implementation through Plutus and deploying and using curl to execute
the Plutus Application Backend.
●
●
●
●
Uniswap in the EUTxO-model.
Uniswap implementation in Plutus.
Deploying Uniswap with the PAB.
Using curl to interact with the PAB.
FORUM AND ASSIGNMENTS
●
●
Complete the assignment on Plutus
Participate in the discussion Forum Questions
6
ACADEMIC YEAR 2021/2022
UNIT /SESSION 13: STUDENT LED Q&A
This ending Module will provide the students an opportunity to review and build upon what has been
learned through the guided creation of Smart contracts using Haskell and Plutus. Session 12 will be a
student led Question and Answer session for clarification.
FORUM AND ASSIGNMENTS
●
Participate in the discussion Forum Questions.
UNIT /SESSION 13 – FINAL EXAM
There will be the requirement for students to work in groups to write on and optionally create
a Smart Contract, decentralized application for transaction using Plutus. Students will be
placed in groups to complete a live coding assignment.
7
ACADEMIC YEAR 2021/2022
COURSE EVALUATION
ASSESSMENT METHODOLOGY
Bonus Points for appearing on zoom.
COURSE WEIGHTINGS
FORUM PARTICIPATION
Forum Week 1 Forum Week 2 Forum Week 3 Forum Week 4 Forum Week 5 Forum Week 6 Forum Week 7 Forum Week 8 Forum Week 9 Forum Week 10 Forum Week 11 Forum Week 12 Forum Week 13 Forum Week 11 -
ASSIGNMENTS
20%
Not applicable- Midterm exam
Not applicable – Final exam
Not applicable – Final exam review
30%
Quiz 1- 5%
Quiz 2- 5%
Quiz 3- 5%
Quiz 4- 5%
Quiz 5- 5%
Quiz 6- 5%
MIDTERM EXAM
20%
FINAL PROJECT
30%
8
ACADEMIC YEAR 2021/2022
BIBLIOGRAPHY
DIDACTIC READINGS
Suggested readings: Books and Journals
Learn You a Haskell for Great Good!: A Beginner's Guide 1st Edition
by Miran Lipovaca (Author)
https://www.amazon.com/Learn-You-Haskell-Great-Good/dp/1593272839
Plutus
Writing Reliable Smart Contracts by
Lars Brünjes, Polina Vinogradova
https://www.amazon.com/Plutus-Writing-reliable-smart-contracts-ebook/dp/B07V46LWTW
Haskell Quick Syntax Reference by
Stefania Loredana Nita
Marius Mihailescu
https://www.amazon.com/Haskell-Quick-Syntax-Reference-Language/dp/1484245067
Andrychowicz, Marcin, Stefan Dziembowski, Daniel Malinowski, Łukasz Mazurek, 2013, Secure
Multiparty Computations on Bitcoin.
Antonopoulos, Andreas, 2015. Mastering Bitcoin.
Back, Adam, Matt Corallo, Luke Dashjr, Mark Friedenbach, Gregory Maxwell, Andrew Miller, Andrew
Poelstra, Jorge Timón, and Pieter Wuille, 2014, Enabling Blockchain Innovations with Pegged
Sidechains
Fortnow, Lance. 2013. The Golden Ticket. Princeton: Princeton University Press.
Goldwasser, Shaffi and Mihir Bellare, 2008, Lecture Notes on Cryptography. [Advanced]
Grinberg, Reuben. 2011, Bitcoin: An Innovative Alternative Digital Currency.
Harvey, Campbell R., 2015, Cryptofinance.
Harvey, Campbell R., 2014, Bitcoin Myths and Facts.
9
ACADEMIC YEAR 2021/2022
Hearn, Mike, 2014. The future of money.
Isaacson, Walter, 2014. The innovators: How a group of hackers, geniuses, and geeks created the
digital revolution. [Amazon link]
King, Ritchie S., Sam Williams, David Yanofsky, 2013, By reading this article, you're mining bitcoins.
Quartz. [Explains mining process and network architecture]
Larimer, Stan. 2103. Bitcoin and the Three Laws of Robotics.
Nakamoto, Satoshi, 2009. Bitcoin: A Peer-to-Peer Electronic Cash System.
Selgin, George. Synthetic Commodity Money.
Szabo, Nick. The idea of smart contracts
Szabo, Nick. Formalizing and Securing Relationships on Public Networks.
10
Download