Week 4 - Plutus Pioneer Program

Notes

Off-chain part

How to write off-chain Plutus code.

Validation functions tend to be fairly simple (relatively) Haskell functions (esp. from needing INLINABLE). Off-chain code though, uses a lot of more advanced Haskell features.

Monads

  • (Relevant portion of video) you don’t need in in let statements within do notation
  • (Relevant portion of video) The Contract monad is used for off-chain code. main gets executed by Haskell, evaluating the ‘recipe’ given by an IO. main should have the type IO () (it seems…).

You can also execute IO in the repl. Putting an IO () directly in the repl will cause it to be executed. E.g. > putStrLn "Hello World".

Bind: (>>=) :: Monad m => m a -> (a -> m b) -> m b)

  • Contract w s e a (Relevant portion of video)
    • w = logging but for communication between contracts or to outside world
    • s = specifies endpoints
    • e = type of error messages
    • a = result type of the Monad, just like list a
  • (Relevant portion of video) Use @String ... to force interpretation as a string when using OverloadedStrings Language Extension
  • (Relevant portion of video) Contract with return type Void cannot throw any exceptions as Void has not possible values.