Lets say I on-chain i have a Datum like so:
data RandomDatum = RandomDatum {
{ tn :: !TokenName
, cs :: !CurrencySymbol
, nn :: !Integer
} deriving (Show)
Off chain I'm trying to form and submit transaction with:
...
let dat = RandomDatum {
tn = ""
, cs = ""
, nn = 1
}
constraints = Constraints.mustPayToOtherScript vh dat val
ledgerTx <- submitTxConstraintsWith lookups constraints
But my compilation always fails, because dat
is not of type Datum
.
I have also tried:
constraints = Constraints.mustPayToOtherScript vh (Datum $ PlutusTx.toBuiltinData dat) val
Question
How could I convert RandomDatum
imported from my on-chain
code file?
PlutusTx.unstableMakeIsData
fails to generate required instances forFromData