Skip to content

Commit

Permalink
Merge branch 'fourth-iteration' into week06
Browse files Browse the repository at this point in the history
  • Loading branch information
rober-m committed Apr 2, 2023
2 parents 9b6b07c + 7a86e05 commit 185e8e4
Show file tree
Hide file tree
Showing 25 changed files with 763 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ keys/
code/Week02/assets/*.tx*
node_modules/
dist/
dist-newstyle/
dist-newstyle/
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"deno.enable": true,
"deno.unstable": true
}
82 changes: 51 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,79 @@
<br>
</h1>

The Plutus Pioneer Program (PPP) is a course delivered by the IOG Education team to recruit and train software developers in Plutus, the native smart contract language for the Cardano ecosystem.
The Plutus Pioneer Program (PPP) is a course delivered by the IOG Education team
to recruit and train software developers in Plutus, the native smart contract
language for the Cardano ecosystem.

This repository contains the lectures, code examples, homework, and installation guides for the new 4th cohort of this program.
This repository contains the lectures, code examples, homework, and installation
guides for the new 4th cohort of this program.

This documentation looks better in GitBook at the following link: <https://iog-academy.gitbook.io/plutus-pioneers-program-fourth-cohort/>
This documentation looks better in GitBook at the following link:
<https://iog-academy.gitbook.io/plutus-pioneers-program-fourth-cohort/>

## Lectures

### [Lecture 1](https://www.youtube.com/playlist?list=PLNEK_Ejlx3x3xFHJJKdyfo9eB0Iw-OQDd)
* [Welcome and Introduction](https://youtu.be/g4fBo4QPir0)
* [Setting up Our Development Environment](https://youtu.be/-cmIqKCzzOU)
* [Kuber Marketplace Demo](https://youtu.be/ZaB-7ZYBi3g)
* [Hashing & Digital Signatures](https://youtu.be/f-WKPWbk9Jg)
* [The EUTxO-Model](https://youtu.be/ulYDNaEKf4g)
* [Homework](https://youtu.be/Ey903I-R1KY)

- [Welcome and Introduction](https://youtu.be/g4fBo4QPir0)
- [Setting up Our Development Environment](https://youtu.be/-cmIqKCzzOU)
- [Kuber Marketplace Demo](https://youtu.be/ZaB-7ZYBi3g)
- [Hashing & Digital Signatures](https://youtu.be/f-WKPWbk9Jg)
- [The EUTxO-Model](https://youtu.be/ulYDNaEKf4g)
- [Homework](https://youtu.be/Ey903I-R1KY)

### [Lecture 2](https://www.youtube.com/playlist?list=PLNEK_Ejlx3x1-oF7NDy0MhXxG7k5O6ZOA)
* [Low-Level, Untyped Validation Scripts](https://youtu.be/3tcWCZV6L_w)
* [Using the Cardano CLI to Interact with Plutus](https://youtu.be/2MbzKzoBiak)
* [High-Level, Typed Validation Scripts](https://youtu.be/GT8OjOzsOb4)
* [Summary](https://youtu.be/F5ewN65Mn4I)
* [Homework](https://youtu.be/OR2IfD4oDjw)

- [Low-Level, Untyped Validation Scripts](https://youtu.be/3tcWCZV6L_w)
- [Using the Cardano CLI to Interact with Plutus](https://youtu.be/2MbzKzoBiak)
- [High-Level, Typed Validation Scripts](https://youtu.be/GT8OjOzsOb4)
- [Summary](https://youtu.be/F5ewN65Mn4I)
- [Homework](https://youtu.be/OR2IfD4oDjw)

### [Lecture 3](https://www.youtube.com/playlist?list=PLNEK_Ejlx3x2zXSjHRKLSc5Jn9vJFA3_O)
* [Script Contexts](https://youtu.be/dcoYrIyEI4o)
* [Handling Time](https://youtu.be/LPzwMqOnWvk)
* [A Vesting Example](https://youtu.be/5D0O7q9UPJA)
* [Parameterized Contracts](https://youtu.be/ZSKVu32c5eA)
* [Offchain Code with Lucid](https://youtu.be/C8TuGSzhqXU)
* [Reference Scripts](https://youtu.be/Rnyc5YXVXew)
* [Homework](https://youtu.be/hdt4XqFeEyg)
* [Summary](https://youtu.be/gxan_u2pStE)

- [Script Contexts](https://youtu.be/dcoYrIyEI4o)
- [Handling Time](https://youtu.be/LPzwMqOnWvk)
- [A Vesting Example](https://youtu.be/5D0O7q9UPJA)
- [Parameterized Contracts](https://youtu.be/ZSKVu32c5eA)
- [Offchain Code with Lucid](https://youtu.be/C8TuGSzhqXU)
- [Reference Scripts](https://youtu.be/Rnyc5YXVXew)
- [Homework](https://youtu.be/hdt4XqFeEyg)
- [Summary](https://youtu.be/gxan_u2pStE)

### [Lecture 4](https://www.youtube.com/playlist?list=PLNEK_Ejlx3x2j587Ox_nwEzmCO-elk8BG)
* [On-chain VS Off-chain](https://youtu.be/pTc_BJby5GU)
* [Off-chain Code with Cardano CLI and GUI](https://youtu.be/gsgQ-xmzbpA)
* [Off-chain Code with Kuber](https://youtu.be/fzib9ALlL2M)
* [Off-chain Code with Lucid](https://youtu.be/BXz5V2rjbiE)
* [Homework](https://youtu.be/2Qm2xgmtbk4)

- [On-chain VS Off-chain](https://youtu.be/pTc_BJby5GU)
- [Off-chain Code with Cardano CLI and GUI](https://youtu.be/gsgQ-xmzbpA)
- [Off-chain Code with Kuber](https://youtu.be/fzib9ALlL2M)
- [Off-chain Code with Lucid](https://youtu.be/BXz5V2rjbiE)
- [Homework](https://youtu.be/2Qm2xgmtbk4)

### [Lecture 5](https://www.youtube.com/playlist?list=PLNEK_Ejlx3x2T1lIR4XnDILKukj3rPapi)

- [Introduction](https://youtu.be/HgXYsMFqnb4)
- [Values](https://youtu.be/ThYByMLC0EI)
- [A Simple Minting Policy](https://youtu.be/g_VoKPK-tk0)
- [A More Realistic Minting Policy](https://youtu.be/Faru8_Br2Xg)
- [NFT's](https://youtu.be/9kW-z_RuwEY)
- [Homework](https://youtu.be/nQC_GNPIRT8)

## Repository Structure

The most relevant directories of this repository are structured as follows:

* In the [.devcontainer](.devcontainer/) directory, you'll find a Docker contained created by the IOG Education Team to create a local development environment for the lectures of this course.
- In the [.devcontainer](.devcontainer/) directory, you'll find a Docker
contained created by the IOG Education Team to create a local development
environment for the lectures of this course.

* In the [docs](docs/) directory, you'll find the lecture notes as they appear in GitBook.
- In the [docs](docs/) directory, you'll find the lecture notes as they appear
in GitBook.

* In the [code](code/) directory, you'll find the code for each lecture.
- In the [code](code/) directory, you'll find the code for each lecture.

---

This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
This work is licensed under a
[Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).

<figure><img src="https://i.creativecommons.org/l/by/4.0/88x31.png" alt="Creative Commons License BY 4.0"></figure>
30 changes: 21 additions & 9 deletions code/Utilities/src/Utilities/Serialise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Utilities.Serialise
( validatorToScript
, policyToScript
, codeToScript
, writeCodeToFile
, writeValidatorToFile
, writePolicyToFile
, dataToJSON
Expand All @@ -15,19 +17,24 @@ import Cardano.Api (Error (displayError), PlutusScript,
writeFileJSON, writeFileTextEnvelope)
import Cardano.Api.Shelley (PlutusScript (..), fromPlutusData,
scriptDataToJsonDetailedSchema)
import Codec.Serialise (serialise, Serialise)
import Codec.Serialise (Serialise, serialise)
import Data.Aeson (Value)
import qualified Data.ByteString.Char8 as BS8
import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.Short as BSS
import Plutus.V1.Ledger.Api (ToData)
import qualified Plutus.V2.Ledger.Api as PlutusV2
import PlutusTx (CompiledCode)
import Text.Printf (printf)


serializableToScript :: Serialise a => a -> PlutusScript PlutusScriptV2
serializableToScript = PlutusScriptSerialised . BSS.toShort . BSL.toStrict . serialise

-- Serialize compiled code
codeToScript :: CompiledCode a -> PlutusScript PlutusScriptV2
codeToScript = serializableToScript . PlutusV2.fromCompiledCode

-- Serialize validator
validatorToScript :: PlutusV2.Validator -> PlutusScript PlutusScriptV2
validatorToScript = serializableToScript
Expand All @@ -36,19 +43,24 @@ validatorToScript = serializableToScript
policyToScript :: PlutusV2.MintingPolicy -> PlutusScript PlutusScriptV2
policyToScript = serializableToScript

-- Create file with Plutus script
writeScriptToFile :: FilePath -> PlutusScript PlutusScriptV2 -> IO ()
writeScriptToFile filePath script =
writeFileTextEnvelope filePath Nothing script >>= \case
Left err -> print $ displayError err
Right () -> putStrLn $ "Serialized script to: " ++ filePath

-- Create file with compiled code
writeCodeToFile :: FilePath -> CompiledCode a -> IO ()
writeCodeToFile filePath = writeScriptToFile filePath . codeToScript

-- Create file with compiled Plutus validator
writeValidatorToFile :: FilePath -> PlutusV2.Validator -> IO ()
writeValidatorToFile filePath validator =
writeFileTextEnvelope filePath Nothing (validatorToScript validator) >>= \case
Left err -> print $ displayError err
Right () -> putStrLn $ "Compiled Plutus script at: " ++ filePath
writeValidatorToFile filePath = writeScriptToFile filePath . validatorToScript

-- Create file with compiled Plutus minting policy
writePolicyToFile :: FilePath -> PlutusV2.MintingPolicy -> IO ()
writePolicyToFile filePath policy =
writeFileTextEnvelope filePath Nothing (policyToScript policy) >>= \case
Left err -> print $ displayError err
Right () -> putStrLn $ "Compiled Plutus script at: " ++ filePath
writePolicyToFile filePath = writeScriptToFile filePath . policyToScript

dataToJSON :: ToData a => a -> Value
dataToJSON = scriptDataToJsonDetailedSchema . fromPlutusData . PlutusV2.toData
Expand Down
9 changes: 8 additions & 1 deletion code/Week05/Week05.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ library
Homework1
Homework2
NFT
Signed
Signed

test-suite week05-homework
import: common-all-tests
type: exitcode-stdio-1.0
main-is: THomework.hs
hs-source-dirs: tests
build-depends: week05
2 changes: 1 addition & 1 deletion code/Week05/assets/free.plutus
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "PlutusScriptV2",
"description": "",
"cborHex": "59078259077f010000323232323232323232323232323233223232323232223232533532320193333573466e1cd55cea801a4000466442466002006004646464646464646464646464646666ae68cdc39aab9d500c480008cccccccccccc88888888888848cccccccccccc00403403002c02802402001c01801401000c008cd4054058d5d0a80619a80a80b1aba1500b33501501735742a014666aa032eb94060d5d0a804999aa80cbae501835742a01066a02a0406ae85401cccd54064085d69aba150063232323333573466e1cd55cea801240004664424660020060046464646666ae68cdc39aab9d5002480008cc8848cc00400c008cd40add69aba15002302c357426ae8940088c98c80b8cd5ce01801701609aab9e5001137540026ae854008c8c8c8cccd5cd19b8735573aa004900011991091980080180119a815bad35742a00460586ae84d5d1280111931901719ab9c03002e02c135573ca00226ea8004d5d09aba2500223263202a33573805805405026aae7940044dd50009aba1500533501575c6ae854010ccd540640748004d5d0a801999aa80cbae200135742a004603e6ae84d5d1280111931901319ab9c028026024135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d55cf280089baa00135742a006601e6ae84d5d1280191931900c19ab9c01a0180163333573466e1cd55ce9baa00448000805c8c98c805ccd5ce00c80b80a880b09931900b19ab9c4910350543500016135573ca00226ea800448c88c008dd6000990009aa80a911999aab9f0012500a233500930043574200460066ae880080508c8c8cccd5cd19b8735573aa004900011991091980080180118061aba150023005357426ae8940088c98c8050cd5ce00b00a00909aab9e5001137540024646464646666ae68cdc39aab9d5004480008cccc888848cccc00401401000c008c8c8c8cccd5cd19b8735573aa0049000119910919800801801180a9aba1500233500f014357426ae8940088c98c8064cd5ce00d80c80b89aab9e5001137540026ae854010ccd54021d728039aba150033232323333573466e1d4005200423212223002004357426aae79400c8cccd5cd19b875002480088c84888c004010dd71aba135573ca00846666ae68cdc3a801a400042444006464c6403666ae7007406c06406005c4d55cea80089baa00135742a00466a016eb8d5d09aba2500223263201533573802e02a02626ae8940044d5d1280089aab9e500113754002266aa002eb9d6889119118011bab00132001355012223233335573e0044a010466a00e66442466002006004600c6aae754008c014d55cf280118021aba200301213574200222440042442446600200800624464646666ae68cdc3a800a40004642446004006600a6ae84d55cf280191999ab9a3370ea0049001109100091931900819ab9c01201000e00d135573aa00226ea80048c8c8cccd5cd19b875001480188c848888c010014c01cd5d09aab9e500323333573466e1d400920042321222230020053009357426aae7940108cccd5cd19b875003480088c848888c004014c01cd5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931900819ab9c01201000e00d00c00b135573aa00226ea80048c8c8cccd5cd19b8735573aa004900011991091980080180118029aba15002375a6ae84d5d1280111931900619ab9c00e00c00a135573ca00226ea80048c8cccd5cd19b8735573aa002900011bae357426aae7940088c98c8028cd5ce00600500409baa001232323232323333573466e1d4005200c21222222200323333573466e1d4009200a21222222200423333573466e1d400d2008233221222222233001009008375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c4664424444444660040120106eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc8848888888cc018024020c030d5d0a8049bae357426ae8940248cccd5cd19b875006480088c848888888c01c020c034d5d09aab9e500b23333573466e1d401d2000232122222223005008300e357426aae7940308c98c804ccd5ce00a80980880800780700680600589aab9d5004135573ca00626aae7940084d55cf280089baa0012323232323333573466e1d400520022333222122333001005004003375a6ae854010dd69aba15003375a6ae84d5d1280191999ab9a3370ea0049000119091180100198041aba135573ca00c464c6401866ae700380300280244d55cea80189aba25001135573ca00226ea80048c8c8cccd5cd19b875001480088c8488c00400cdd71aba135573ca00646666ae68cdc3a8012400046424460040066eb8d5d09aab9e500423263200933573801601200e00c26aae7540044dd500089119191999ab9a3370ea00290021091100091999ab9a3370ea00490011190911180180218031aba135573ca00846666ae68cdc3a801a400042444004464c6401466ae7003002802001c0184d55cea80089baa0012323333573466e1d40052002200623333573466e1d40092000212200123263200633573801000c00800626aae74dd5000a4c2400224400492010350543100112323001001223300330020020011"
"cborHex": "5830582e010000323222320053333573466e1cd55ce9baa0024800080148c98c8014cd5ce249035054310000500349848005"
}

This file was deleted.

Loading

0 comments on commit 185e8e4

Please sign in to comment.