0

I was hoping to get some advice re printing a plutus validators cborhex to a file. Im kinda basing my logic off of an example in week03 in the pioneer program but need to make some adaptations.

Below is how i've created the validator, followed by how I'm trying to serialize and print to file:

tradeValidate :: ContractInfo -> TradeDatum -> TradeAction -> ScriptContext -> Bool
tradeValidate contractInfo@ContractInfo{..} tradeDatum tradeAction context = case tradeDatum of
    StartBid -> case tradeAction of
...etc

      
data Trade
instance Scripts.ValidatorTypes Trade where
    type instance RedeemerType Trade = TradeAction
    type instance DatumType Trade = TradeDatum

tradeInstance :: Scripts.TypedValidator Trade
tradeInstance = Scripts.mkTypedValidator @Trade
    ($$(PlutusTx.compile [|| tradeValidate ||]) `PlutusTx.applyCode` PlutusTx.liftCode contractInfo)
    $$(PlutusTx.compile [|| wrap ||])
  where
    wrap = Scripts.wrapValidator @TradeDatum @TradeAction

tradeValidator :: Validator
tradeValidator = Scripts.validatorScript tradeInstance

writeValidator :: FilePath -> Plutus.Validator -> IO (Either (FileError ()) ())
writeValidator file = writeFileTextEnvelope @(PlutusScript PlutusScriptV1) file Nothing . PlutusScriptSerialised . SBS.toShort . LBS.toStrict . serialise . Ledger.unValidatorScript

writeTradeValidator :: IO (Either (FileError ()) ())
writeTradeValidator = writeValidator "trade.plutus" $ tradeValidator[???]

Where I've put tradeValidator is incorrect, but I'm not sure what do put in its place

The example I'm taking from did this:

writeVestingValidator :: IO (Either (FileError ()) ())
writeVestingValidator = writeValidator "testnet/vesting3.plutus" $ validator $ VestingParam
    { beneficiary = Ledger.PaymentPubKeyHash "c5a3dc50d72f46ecca258c04bd5e3da5717863e358af7e1b361f9487"
    , deadline    = 1664683478000
    }
0

1 Answer 1

0

What specific error messages do you get? From Haskell standpoint there is an extra $ in your code, try this maybe:

writeTradeValidator :: IO (Either (FileError ()) ())
writeTradeValidator = writeValidator "trade.plutus" tradeValidator
1
  • Amazing thank you so much that was it!! :D Oct 7, 2022 at 3:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.