0

I created this datum with Mesh

  const datumMD: Data = new Map<Data, Data>();
  datumMD.set('name', assetName );
  datumMD.set('question', input);
  datumMD.set('answers', []);
  datumMD.set('results', []);
  
  const datumState: Data = new Map<Data, Data>();
  datumState.set('state', 'INIT');

  const datumMetadata: Data = {
    alternative: 0,
    fields: [datumMD, datumState]
  };

The CBOR of that is:

d8799fa447616e737765727380446e616d654a70726f706f73616c2d33487175657374696f6e53446f657320697420776f726b3f20486d6d6d3f47726573756c747380a145737461746544494e4954ff

What would the type of that datum be in Plutus (Haskell)?

4
  • When creating datumMD you are using keys of type String but values of different types. In Haskell, Maps, just like lists, are homogenous, therefore you cannot have lists, then strings, then ... in the same map's values. I cannot help further, correct this and then we'll see how to translate your datum to a Haskell data type. Also, I'm interested in why you are doing it this way (Mesh -> Plutus) instead of the usual (Plutus -> Mesh)? Thanks in advance for the clarification :) Jan 15 at 10:10
  • It seems to work, the CBOR of this datum is this: d8799fa447616e737765727380446e616d654a70726f706f73616c2d31487175657374696f6e576e696b6f73203234206c6570746120706172616b616c7747726573756c747380a145737461746544494e4954ff So maybe its considered all Map of Data ?
    – Kavvadias
    Jan 15 at 10:49
  • Could it be that its data DatumMetadata = DatumMetadata { datumMD :: ![(BuiltinData, BuiltinData)], datumState :: ![(BuiltinData, BuiltinData)]}
    – Kavvadias
    Jan 15 at 10:53
  • I did the Mesh -> Plutus because i needed the datum first on the OffChain part, i didnt use it that much onChain.
    – Kavvadias
    Jan 15 at 10:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.