Closed aleeusgr closed 1 year ago
Lines 1: 12 are extensions 15: 18 - FaucetValidatorScript has 2 parameters: FaucetParam and Validator..?? 21:31 - Imports.
import Data.Aeson (ToJSON, FromJSON)
means only 2 functions are imported
data FaucetParams = FaucetParams
{ accessTokenSymbol :: !CurrencySymbol
, accessTokenName :: !TokenName
, faucetTokenSymbol :: !CurrencySymbol
, faucetTokenName :: !TokenName
, withdrawalAmount :: !Integer
} deriving (Pr.Eq, Pr.Ord, Show, Generic, ToJSON, FromJSON, ToSchema)
makeLift unstableMakeIsData - ??
55. PlutusTx.makeLift ''FaucetParams
...
59. PlutusTx.unstableMakeIsData ''FaucetRedeemer
60. PlutusTx.makeLift ''FaucetRedeemer
newtype FaucetRedeemer
- ??
PubKeyHash
newtype FaucetRedeemer = FaucetRedeemer {senderPkh :: PubKeyHash}
faucetValidator :: FaucetParams -> Integer -> FaucetRedeemer -> ScriptContext -> Bool
faucetValidator faucet _ receiver ctx = traceIfFalse "Input needs PPBL2022AccessToken" inputHasAccessToken &&
traceIfFalse "PPBL2022AccessToken must return to sender" outputHasAccessToken &&
traceIfFalse "Faucet token must be distributed to sender" outputHasFaucetToken &&
traceIfFalse "Must return remaining tokens to contract" faucetContractGetsRemainingTokens &&
traceIfFalse "Do we need to check datum" checkDatumIsOk
mkValidator :: TestParam -> Integer -> () -> Plutus.ScriptContext -> Bool
mkValidator param dat _ _ = dat == testNumber param```
makeLift
- low level haskell function for deriving instances in order to make data usable in plutus-core
unstableMakeIsData
- deriving instances for haskell function to understand JSON format for this data type in a particular order
newtype
- same as data declaration, just for this data type, there is only one value constructor with one element stored inside. This is introduced for efficiency purposes
-- upon basic research, you can try to implement the 3 contracts into endpoints as described at #25
SIDAN.createEndpoint "get-parameterized-script" $ SIDAN.mkV1Validator V1V.validator
So how does that work?
If Validator confirms the details of a transaction, it [signals the on-chain part to execute it].
This is a gated faucet, it generates tokens out of thin air. It could be used in a economic loop where tokens are constantly created and burned, E.g.: On-Chain Governance of Decentralized Autonomous Organizations: Blockchain Organization Using Semada, Calcaterra C.
To get your free tokens, you need a transaction (link to (how to create a transaction), and an [Auth Token].
We could take this discussion offline. The use case should be covered in PPBL or other Gimbalabs resources. Closing as the integration with examples are completed
@SIDANWhatever — Yesterday at 17:56
https://gitlab.com/gimbalabs/plutus-pbl-summer-2022/ppbl-course-02/-/tree/master/project-301-faucet