2021-04-08 12:07:47 +02:00
# Plutus Pioneer Program
## Lectures
- [Lecture #1 ](https://youtu.be/IEn6jUo-0vU )
- Welcome
- The (E)UTxO-model
- Running an example auction contract on a local Playground
- Homework
2021-04-13 12:48:07 +02:00
- [Lecture #2 ](https://youtu.be/E5KRk5y9KjQ )
- Triggering change.
- Low-level, untyped on-chain validation scripts.
- High-level, typed on-chain validation scripts.
2021-04-20 09:09:21 +02:00
- [Lecture #3 ](https://youtu.be/Lk1eIVm_ZTQ )
- Script context.
- Time handling.
- Parameterized contracts.
2021-04-27 09:14:58 +02:00
- [Lecture #4 ](https://youtu.be/6Reuh0xZDjY )
- Monads
- The `EmulatorTrace` monad.
- The `Contract` monad.
2021-05-05 21:46:44 +02:00
- [Lecture #5 ](https://youtu.be/6VbhY162GQA )
- Values.
- Native tokens & minting policies.
- NFT's.
2021-05-12 19:40:33 +02:00
- [Lecture #6 ](https://youtu.be/wY7R-PJn66g )
- Oracles.
- Using the PAB.
2021-05-20 00:35:48 +02:00
- [Lecture #7 ](https://youtu.be/oJupInqvJUI )
- Commit schemes.
- State machines.
2021-05-27 08:33:05 +02:00
- [Lecture #8 ](https://youtu.be/JMRwkMgaBOg )
- Another state machine example: token sale.
- Automatic testing using emulator traces.
- Interlude: optics.
- Property based testing with `QuickCheck` .
- Testing Plutus contracts with property based testing.
2021-06-03 01:07:19 +02:00
- [Lecture #9 ](https://youtu.be/-RpCqHuxfQQ )
2021-06-10 10:32:29 +02:00
- Marlowe overview ([slides](Marlowe_Plutus_Pioneers_June_2021.pdf)).
- Marlowe in Plutus.
- Marlowe Playground demo.
- [Lecture #10 ](https://youtu.be/Dg36h9YPMz4 )
- Uniswap overview.
- Uniswap implementation in Plutus.
- Deploying Uniswap with the PAB.
- Demo.
- Using `curl` to interact with the PAB.
2021-06-03 01:07:19 +02:00
2021-04-08 12:07:47 +02:00
## Code Examples
2021-06-10 10:32:29 +02:00
- Lecture #1: [English Auction ](code/week01 )
- Lecture #2: [Simple Validation ](code/week02 )
- Lecture #3: [Validation Context & Parameterized Contracts ](code/week03 )
- Lecture #4: [Monads, `EmulatorTrace` & `Contract` ](code/week04 )
- Lecture #5: [Minting Policies ](code/week05 )
- Lecture #6: [Oracles ](code/week06 )
- Lecture #7: [State Machines ](code/week07 )
- Lecture #8: [Testing ](code/week08 )
- Lecture #9: [Marlowe ](code/week09 )
- Lecture #10: [Uniswap ](code/week10 )
2021-04-08 12:07:47 +02:00
2021-04-08 12:15:17 +02:00
## Exercises
- Week #1
Improve instructions
When running `cabal build`, I ran into this issue:
```
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.RemoteRepo {remoteRepoName = RepoName
"hackage.haskell.org", remoteRepoURI = http://hackage.haskell.org/,
remoteRepoSecure = Just True, remoteRepoRootKeys =
["fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0","1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42","2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3","0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d","51f0161b906011b52c6613376b1ae937670da69322113a24
6a09f807c62f6921"],
remoteRepoKeyThreshold = 3, remoteRepoShouldTryHttps = True}
Warning: Requested index-state 2021-02-24T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state ().
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: byron-spec-chain-0.1.0.0 (user goal)
[__1] unknown package: microlens-th (dependency of byron-spec-chain)
[__1] fail (backjumping, conflict set: byron-spec-chain, microlens-th)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: byron-spec-chain, microlens-th
```
As described, I needed to run `cabal update` first. It could be helpful to have it in the README to help some people get started
2021-04-08 18:41:28 +02:00
- Build the [English Auction ](code/week01 ) contract with `cabal build` (you may need to run `cabal update` first).
2021-04-08 12:15:17 +02:00
- Clone the [The Plutus repository ](https://github.com/input-output-hk/plutus ), check out the correct commit
as specified in [cabal.project ](code/week01/cabal.project ).
2021-04-09 09:36:15 +02:00
- Set-up IOHK binary caches [How to set up the IOHK binary caches ](https://github.com/input-output-hk/plutus#iohk-binary-cache ). "If you do not do this, you will end up building GHC, which takes several hours. If you find yourself building GHC, STOP and fix the cache."
2021-04-08 12:15:17 +02:00
- Enter a `nix-shell` .
- Go to the `plutus-playground-client` folder.
- Start the Playground server with `plutus-playground-server` .
- Start the Playground client (in another `nix-shell` ) with `npm run start` .
- Copy-paste the auction contract into the Playground editor - don't forget to remove the module header!
- Compile.
- Simulate various auction scenarios.
2021-04-13 16:44:22 +02:00
- Week #2
- Fix and complete the code in the [Homework1 ](code/week02/src/Week02/Homework1.hs ) module.
- Fix and complete the code in the [Homework2 ](code/week02/src/Week02/Homework2.hs ) module.
2021-04-20 09:09:21 +02:00
- Week #3
2021-04-20 11:35:50 +02:00
- Fix and complete the code in the [Homework1 ](code/week03/src/Week03/Homework1.hs ) module.
- Fix and complete the code in the [Homework2 ](code/week03/src/Week03/Homework2.hs ) module.
2021-04-20 09:09:21 +02:00
2021-04-27 09:14:58 +02:00
- Week #4
- Write an appropriate `EmulatorTrace` that uses the `payContract` contract in the [Homework ](code/week04/src/Week04/Homework.hs ) module.
- Catch errors in the `payContract` contract in the same module.
2021-04-20 09:09:21 +02:00
2021-05-05 21:46:44 +02:00
- Week #5
- Add a deadline to the minting policy in the [Homework1 ](code/week05/src/Week05/Homework1.hs ) module.
- Fix the token name to the empty `ByteString` in the NFT contract in the [Homework2 ](code/week05/src/Week05/Homework2.hs ) module.
2021-05-12 19:40:33 +02:00
- Week #6
- Get the Oracle demo running and extend it in some way.
2021-05-20 00:35:48 +02:00
- Week #7
- Implement the game of "Rock, Paper, Scissors" using state machines.
2021-05-27 08:33:05 +02:00
- Week #8
- Add a new operation `close` to the `TokenSale` -contract that allows the seller to close the contract and
retrieve all remaining funds (including the NFT).
- Modify the tests accordingly.
2021-06-03 01:07:19 +02:00
- Week #9
- Modify the example Marlowe contract, so that Charlie must put down twice the deposit in the very beginning,
which gets split between Alice and Bob if Charlie refuses to make his choice.
2021-06-10 10:32:29 +02:00
- Week #10
- Get the Uniswap demo running and extend it in some way.
2021-04-14 16:42:16 +02:00
## Solutions
- Week #2
- [`Homework1` ](code/week02/src/Week02/Solution1.hs )
- [`Homework2` ](code/week02/src/Week02/Solution2.hs )
2021-04-20 11:36:21 +02:00
- Week #3
- [`Homework1` ](code/week03/src/Week03/Solution1.hs )
- [`Homework2` ](code/week03/src/Week03/Solution2.hs )
2021-05-05 21:46:44 +02:00
- Week #4
- [`Homework` ](code/week04/src/Week04/Solution.hs )
2021-05-12 19:40:33 +02:00
- Week #5
- [`Homework1` ](code/week05/src/Week05/Solution1.hs )
- [`Homework2` ](code/week05/src/Week05/Solution2.hs )
2021-05-20 00:40:18 +02:00
- Week #7
- [`RockPaperScissors` ](code/week07/src/Week07/RockPaperScissors.hs )
- [`TestRockPaperScissors` ](code/week07/src/Week07/TestRockPaperScissors.hs )
2021-06-03 01:15:15 +02:00
- Week #8
- [`TokenSaleWithClose` ](code/week08/src/Week08/TokenSaleWithClose.hs )
- [`ModelWithClose` ](code/week08/test/Spec/ModelWithClose.hs )
- [`TraceWithClose` ](code/week08/test/Spec/TraceWithClose.hs )
- Week #9
- [`solution` ](code/week09/app/solution.hs )
2021-04-12 11:29:45 +02:00
## Some Plutus Modules
2021-06-03 01:07:19 +02:00
- [`Language.Marlowe.Semantics` ](https://github.com/input-output-hk/plutus/blob/master/marlowe/src/Language/Marlowe/Semantics.hs ), contains Marlowe types and semantics.
2021-05-20 00:35:48 +02:00
- [`Plutus.Contract.StateMachine` ](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Contract/StateMachine.hs ), contains types and functions for using state machines.
2021-05-27 08:33:05 +02:00
- [`Plutus.Contract.Test` ](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Contract/Test.hs ), provides various ways to write tests for Plutus contracts.
- [`Plutus.Contract.Test.ContractModel` ](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Contract/Test/ContractModel.hs ), support for property based testing of Plutus contracts.
2021-06-10 10:32:29 +02:00
- [`Plutus.Contracts.Uniswap` ](https://github.com/input-output-hk/plutus/blob/master/plutus-use-cases/src/Plutus/Contracts/Uniswap.hs ), an implementation of Uniswap in Plutus.
2021-05-12 19:40:33 +02:00
- [`Plutus.PAB.Webserver.API` ](https://github.com/input-output-hk/plutus/blob/master/plutus-pab/src/Plutus/PAB/Webserver/API.hs ), contains the HTTP-interface provided by the PAB.
2021-04-27 09:14:58 +02:00
- [`Plutus.Trace.Emulator` ](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Trace/Emulator.hs ), contains types and functions related to traces.
2021-05-05 21:46:44 +02:00
- [`Plutus.V1.Ledger.Ada` ](https://github.com/input-output-hk/plutus/blob/master/plutus-ledger-api/src/Plutus/V1/Ledger/Ada.hs ), contains support for the Ada currency.
2021-04-18 22:49:27 +02:00
- [`Plutus.V1.Ledger.Contexts` ](https://github.com/input-output-hk/plutus/blob/master/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs ), contains the definition of the context-related types.
- [`Plutus.V1.Ledger.Interval` ](https://github.com/input-output-hk/plutus/blob/master/plutus-ledger-api/src/Plutus/V1/Ledger/Interval.hs ), contains the definition of and helper functions for the `Interval` type.
- [`Plutus.V1.Ledger.Slot` ](https://github.com/input-output-hk/plutus/blob/master/plutus-ledger-api/src/Plutus/V1/Ledger/Slot.hs ), contains the definition of the `Slot` type.
2021-05-05 21:46:44 +02:00
- [`Plutus.V1.Ledger.Value` ](https://github.com/input-output-hk/plutus/blob/master/plutus-ledger-api/src/Plutus/V1/Ledger/Value.hs ), contains the definition of and helper functions for the `Value` type.
2021-04-12 11:29:45 +02:00
- [`PlutusTx.Data` ](https://github.com/input-output-hk/plutus/blob/master/plutus-tx/src/PlutusTx/Data.hs ), contains the definition of the `Data` type.
2021-04-12 22:59:51 +02:00
- [`PlutusTx.IsData.Class` ](https://github.com/input-output-hk/plutus/blob/master/plutus-tx/src/PlutusTx/IsData/Class.hs ), defines the `IsData` class.
2021-04-12 11:29:45 +02:00
2021-04-22 13:35:44 +02:00
## Plutus community playground
2021-04-22 11:37:41 +02:00
- [Week 1 Community Playground(Legacy) ](https://playground-week1.plutus-community.com/ )
- [Week 2 Community Playground(Legacy) ](https://playground-week2.plutus-community.com/ )
2021-05-02 20:13:43 +02:00
- [Week 3 Community Playground(Current) ](https://playground-week3.plutus-community.com/ )
- [Week 4 Community Playground(Current) ](https://playground.plutus-community.com/ )
2021-04-22 11:37:41 +02:00
2021-04-08 12:07:47 +02:00
## Additional Resources
2021-04-08 12:15:17 +02:00
- [The Plutus repository ](https://github.com/input-output-hk/plutus )
- [Learn You a Haskell for Great Good! ](http://learnyouahaskell.com/ )
2021-04-08 12:07:47 +02:00
- [Haskell & Cryptocurrencies course Mongolia ](https://www.youtube.com/playlist?list=PLJ3w5xyG4JWmBVIigNBytJhvSSfZZzfTm )