0

I'm having the following sample contract, where I'm trying to pass the record value as a parameter and also want to pass empty map as storage; can someone help me?

type string_rec = {
  a : string; 
  b : string
}

type parameter =
  Add of string_rec
| Get of string_rec

type storage = (string, string_rec) map

type return = operation list * storage

let add (store, k : storage * string_rec) : storage = 
  Map.add("abc" : string) (k) store

let get (store, k : storage * string_rec) : storage = 
  Map.add("abc" : string) (k) store

let main (action, store : parameter * storage) : return =
 ([] : operation list),
 (match action with
   Add n -> add (store, n)
 | Get n -> get (store, n))

1 Answer 1

0

(1) a record will be translated into a nested pair-structure, so you need to have something like this (Pair "string 1" "string 2").

(2) you can't pass a storage to an existing contract. You can only initialize a contract storage during its origination. An empty map is written as {}.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.