<p>What specific error messages do you get? From Haskell standpoint there is an extra <code>$</code> in your code, try this maybe:</p>
<pre class="lang-haskell prettyprint-override"><code>writeTradeValidator :: IO (Either (FileError ()) ())
writeTradeValidator = writeValidator &quot;trade.plutus&quot; tradeValidator
</code></pre>

CC BY-SA 4.0
2022-10-07T03:44:57.767Z
Amazing thank you so much that was it!! :D
NaeriKailash
CC BY-SA 4.0
2022-10-07T03:26:18.907Z
2022-10-07T03:26:18.907Z
SIDAN Whatever
<p>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.</p>
<p>Below is how i've created the validator, followed by how I'm trying to serialize and print to file:</p>
<pre><code>tradeValidate :: ContractInfo -&gt; TradeDatum -&gt; TradeAction -&gt; ScriptContext -&gt; Bool
tradeValidate contractInfo@ContractInfo{..} tradeDatum tradeAction context = case tradeDatum of
    StartBid -&gt; 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 -&gt; Plutus.Validator -&gt; IO (Either (FileError ()) ())
writeValidator file = writeFileTextEnvelope @(PlutusScript PlutusScriptV1) file Nothing . PlutusScriptSerialised . SBS.toShort . LBS.toStrict . serialise . Ledger.unValidatorScript

writeTradeValidator :: IO (Either (FileError ()) ())
writeTradeValidator = writeValidator &quot;trade.plutus&quot; $ tradeValidator[???]
</code></pre>
<p>Where I've put tradeValidator is incorrect, but I'm not sure what do put in its place</p>
<p>The example I'm taking from did this:</p>
<pre><code>writeVestingValidator :: IO (Either (FileError ()) ())
writeVestingValidator = writeValidator &quot;testnet/vesting3.plutus&quot; $ validator $ VestingParam
    { beneficiary = Ledger.PaymentPubKeyHash &quot;c5a3dc50d72f46ecca258c04bd5e3da5717863e358af7e1b361f9487&quot;
    , deadline    = 1664683478000
    }
</code></pre>

<plutus><plutus-pioneer-program><smart-contract><haskell>
Printing a plutus validators cborhex to a file
# Printing a plutus validators cborhex to a file

(Asked by: username_0 on 2022-10-06)

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
    }

**Tags:** plutus, plutus-pioneer-program, smart-contract, haskell

---

## 1 answers

### Answer by username_1 on 2022-10-07. Score: 0 | Accepted answer

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

> **Comments:**
> **username_0**: Amazing thank you so much that was it!! :D  

---

