1

How do I test different plutus functions to see if its applicable to be used in my code. How would I create the parameters that these functions would take in.

For example below is a Vesting contract from the Plutus-Pionner-Program. How do i see what happenes when you run this function.How do I test out what each individual function return when a parameter is passed in.

give :: AsContractError e => GiveParams -> Contract w s e ()
give gp = do
    let dat = VestingDatum
                { beneficiary = gpBeneficiary gp
                , deadline    = gpDeadline gp
                }
        tx  = Constraints.mustPayToTheScript dat $ Ada.lovelaceValueOf $ gpAmount gp
    ledgerTx <- submitTxConstraints typedValidator tx
    void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
    logInfo @String $ printf "made a gift of %d lovelace to %s with deadline %s"
        (gpAmount gp)
        (show $ gpBeneficiary gp)
        (show $ gpDeadline gp)

How would I pass in the necessary information to this to test if it runs or not.

Basically what I am asking is how do i just start hacking on Plutus. Just run some of the functions that Plutus have ,pass in some parameters , and see what it returns. I know i can run it in GHCI but I feel like I have some gaps in my knowledge and it is not connecting yet.

1
  • I share your dilemma. I am no expert, but my understanding is that whereas other languages tend to be imperative (do this to that, and then take that and do this to it), Haskell is more about defining what something is. Therefore, there is no interim state or progress status to easily query or capture (eg. alert('here!'); in javascript). Add to that the multi-nested user defined (often other-user defined ie. plutus development team) types and "builtin" types and the need to define instances to view something (eg. deriving Show) in your code, and I too find myself wandering blind and lost.
    – XiTouch
    Mar 29, 2022 at 14:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.