When users will call the register_user
transition, they'll have to provide some data to the transition so that they could be uniquely registered. We’ll ask the users to provide:
We have covered this in the first chapter but for a quick reference, in case we want to declare multiple parameters for a transition, then we can do so by separating the parameter names and types by commas, as shown below:
In the bracket after the transitionregister_user
declare two variables:
user_address
of the type ByStr20
. This will hold the wallet address of the user.twitter_username
of the type String
. This will hold the twitter id of the user.Show Solution
scilla_version 0
import BoolUtils
library SocialMediaPayment
let one_msg =
fun (msg: Message) =>
let nil_msg = Nil {Message} in
Cons {Message} msg nil_msg
let zero = Uint128 0
let not_owner_code = Uint32 1
let accepted_code = Uint32 0
contract SocialMediaPayment (owner: ByStr20)
transition deposit()
sender_is_owner = builtin eq _sender owner;
match sender_is_owner with
| False =>
msg = { _tag: "";
_recipient: _sender;
_amount: zero;
code: not_owner_code};
msgs = one_msg msg;
send msgs
| True =>
accept;
msg = { _tag: "";
_recipient: _sender;
_amount: zero;
code: accepted_code};
msgs = one_msg msg;
send msgs
end
end
(*type within the brackets in the line below *)
transition register_user ()
end
12345678910111213141516171819202122232425262728293031323334353637383940414243444546