I was trying to deploy a vote smart contract on Tezos using tezos-client but because of initilization issue nothing was happening the right way.
The smart contract code in liquidity ( you can see the Mickelson code by compiling it with https://www.liquidity-lang.org/edit/ ):
[%%version 0.9] type storage = { candidates: (string, int) map ; voters: (address, bool) map } [%%init let init_candidates (candidate_names : string list) = let candidates = List.fold (fun (elt,map) -> Map.add elt 0 map) candidate_names (((Map ([]))[@explicit_arity ]) : (string, int) map) in { candidates = candidates; voters = (Map : (address, bool) map) } ] [%%entry let main (parameter : string) (storage : storage) = let stroage = storage.candidates <- (match Map.find parameter storage.candidates with | None -> failwith ("Candidate is not valid", parameter) | ((Some (x))[@explicit_arity ]) -> Map.add parameter (x + 1) storage.candidates) in (([] : operation list), storage) ] Command used to deploy:
./tezos-client originate contract vote transferring 0 from alice running ../vote.tz --init '["Alice" ; "Bob" ; "Jack"]' --burn-cap 0.429 Error:
At line 1 character 0, unexpected character [ At line 1 character 27, unexpected character ] At line 1 characters 9 to 10, unexpected semi colon At line 1 characters 11 to 17, unexpected string constant At line 1 characters 18 to 19, unexpected semi colon At line 1 characters 20 to 27, unexpected string constant I found an other way to initiate the storager using "Paie" and "Elt", so I tried to deploy:
./tezos-client originate contract votesec transferring 0 from Khalil running ../vote.tz --init '(Pair {Elt "Alice" 0 ; Elt "Bob" 0})' And I got this error:
Ill typed data: 1: (Pair { Elt "Alice" 0 ; Elt "Daly" 0 }) is not an expression of type pair :storage (map %candidates string int) (map %voters address bool) At line 1 characters 0 to 38, primitive Pair expects 2 arguments but is given 1. Can anyone help me out and explain to me what's wrong?
Thank you in advance.
--init '(Pair { Elt "Alice" 0 ; Elt "Daly" 0 } {})'