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
ininletstatements withindonotation -
(Relevant portion of video) The Contract monad is used for off-chain code.
maingets executed by Haskell, evaluating the ‘recipe’ given by anIO.mainshould have the typeIO ()(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
Voidcannot throw any exceptions asVoidhas not possible values.