I have two main actions that user can do. They both require sending utxos to a script address. The datum I want produced by these two actions are different. I want one of the datum like this
data VotingDatum = VotingDatum
{ projectPubKey :: PaymentPubKeyHash
, amount :: Integer
, fund :: Integer
, paymentPubKey :: PaymentPubKeyHash
}deriving (Show)
and the other one like this.
data StartDatum = StartDatum
{ startFund :: Integer
, fundPrize :: Integer
}deriving (Show)
I was thinking of putting these two in a single data type like this
data ContractDatum = ContractDatum
{ voteDatum :: Maybe VotingDatum
, startDatum :: Maybe StartDatum
}
How would i set the value of these fields if i did it like this. Can i do it like this ? I am currently setting the value of the types like this
start sp = do
let dat = StartDatum
{ startFund = spFund sp
, fundPrize = spAmount sp
}
How can i have two different data types for the datum. How can i set the value of it , and how would i access the value of it.