Closed aleeusgr closed 1 year ago
https://iohk.io/en/blog/posts/2021/04/13/plutus-what-you-need-to-know/
EUTXO extends the UTXO model by allowing output addresses to contain complex logic to decide which transactions can unlock them, and by adding custom data to all outputs.
Plutus Core All Plutus Core programs are generated by a Haskell compiler plugin.
These scripts will be executed by nodes during transaction validation ‘live’ on the chain. They will either lock UTXOs in the form of validator scripts or as minting policies,
Redeemer data is a simple (algebraic) data type
PAF
Many applications need to watch the UTXO set for changes to particular addresses, so if we write our contract as a state machine, we need to track the unspent output that represents the current state of the machine and update our local state when the on-chain state changes. Likewise, many apps need to communicate with the wallet backend to access the crypto currency that they are using for transactions.
Applications written on top of the PAF automatically provide an HTTP and WebSocket interface that can be used to interact with the application from the web browser.
The Plutus Application Framework (PAF) ‒ Plutus contracts consist of parts that run on the blockchain (on-chain code) and parts that run on a user’s machine (off-chain or client code)
PAB is a single Haskell library
Offchain code is compiled by ghc, and on-chain code is what is compiled by plutus.
addresses in the EUTXO model can contain arbitrary logic in the form of scripts.
https://plutus-pioneer-program.readthedocs.io/en/latest/pioneer/week4.html
test for dApp is a transaction.
T | F
How a new feature is created?
User story, product requirements, specification.
A unit test.
Often a feature would include several components; What is the purpose of an integration test?
System testing
Acceptance testing
What is monad and why it is used?
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.
The on-chain part that we have seen so far is somewhat alien and takes a little getting used to, due to the fact that we have the additional complication of the compilation to Plutus script.
INLINABLE
Haskell inside validation will be relatively simple
so-called effect systems
how IO side-effects are handled in Haskell
In Java we don't know if result of a function will be the same for same arguments because in Java a function can read a file or user input and provide output based on that input.
Functional languages are simpler to test;
Simon Peyton-Jones
IO Monad:
referential transparency;
IO should be inside main
There are a variety of IO actions defined in Haskell
a way to combine these primitive, provided IO actions into bigger, more complex recipes.
Functor, a type class.
fmap (map toUpper) getLine :: IO [Char]
>>
chain operator
>>=
bind
The logic of the game is to guess a word, compare it to a secret and share some money if the word is right. + nft for IAM
The generated tests will exercise the contract by locking the prize, then moving the game token and making guesses at random, checking that the game token and Ada move as they should.
Actions: lock the prize move game token make a guess check reciever wallet
taking the application through a wide variety of states, and checking that it behaves correctly in each one.
What are states for the Escrow contract? What Escrow does, is take crypto, hodl, and release upon a request.
Guessing game is an Escrow contract with extended functionality: it limits the set of agents who could open it to one, using NFT for IAM; it's validator is simple comparison against a stored value.
There are other actions that validator could perform.
Reading README: [2/35]
PAB: serve and interact with contracts over a web API;
curl -s http://localhost:9080/api/contract/definitions | jq
You should receive a list of contracts and the endpoints that can be called on them, and the arguments required for tho se endpoints.
PAB is an example of a plutus-app; T | F?
I wonder, I can explore SIDAN vs PAB; if I can integrate SIDAN inte plutus-starter, I will get CI for free. This aligns with the process of developing secure dApps;
A task idea:
Validator script is the lock; plutus-apps is the only kind of key that can open such a lock; PAB is the endpoint; it accepts web requests, processess them and sends them to blockchain: PAB -> cli -> cardano-node.