I have 4 different Datum Data Types in my script because for 4 different use cases in my script.
data FundCreationDatum = FundCreationDatum
{ vFundOwner :: PaymentPubKeyHash,
vPrizeAmount :: Integer,
vProjectLabel :: [BuiltinByteString],
vPrizeDistributionRatio :: [Integer]
}
data ProjectSubmitDatum = ProjectSubmitDatum
{ vProjectOwner :: PaymentPubKeyHash,
vProjectRegistrationFee :: Integer,
vProjectCategory :: BuiltinByteString,
vFundPayIdentifier :: PaymentPubKeyHash
}
data VotingActionDatum = VotingActionDatum
{ vProjectToVote :: PaymentPubKeyHash,
vVoterPayAddress :: PaymentPubKeyHash,
vAdaLovelaceValue :: Integer,
vVoteFundIdentifier :: PaymentPubKeyHash,
vActionName :: BuiltinByteString
}
deriving (Show)
data ConToMatchPool = ConToMatchPool
{ vFundAddress :: PaymentPubKeyHash,
vPrizeFund :: Integer
}
deriving (Show)
I then bundled the 4 data types into a single data type with the Maybe monad.
data QuadraDatum = QuadraDatum
{ qCreateFund :: (Maybe FundCreationDatum),
qVoting :: (Maybe VotingActionDatum),
qSubProject :: (Maybe ProjectSubmitDatum),
qContrPool :: (Maybe ConToMatchPool)
}
I am trying to send a utxo with datum attached like this.
start cp = do
let dat = QuadraDatum qContrPool
{vFundOwner = cpFundOwner cp
,vPrizeAmount = cpPrizeAmount cp
,vProjectLabel = cpProjectLabel cp
,vPrizeDistributionRatio = cpPrizeDistributionRatio cp
}
tx = Constraints.mustPayToTheScript dat $ Ada.lovelaceValueOf $ (cpPrizeAmount cp)
ledgerTx <- submitTxConstraints typedValidator tx
void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
I am getting the following error
error:
• Couldn't match expected type ‘Maybe FundCreationDatum’
with actual type ‘FundCreationDatum’