Earlier, in the first chapter, we stored user names using variables. However, there might be thousands (or millions) of users for an application. We will need a better way to store those names, than the ones we discussed in the last chapter.
Before we move towards that objective, first let’s simply create a transition which will collect information from the user and allow them to register.
After the end of the previous transition, declare a new transition
with the name register_user
. You can currently leave the brackets after the transition name empty. Also, make sure to end the declaration of the transition with end
keyword.
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
(* Start typing from the line below *)
123456789101112131415161718192021222324252627282930313233343536373839404142