scilla-docs
scilla-docs copied to clipboard
Add multi-message example
Note to remove: https://github.com/Zilliqa/scilla-docs/blob/6559e81037c0090088a9a1f27c19a0617cd2df0f/docs/source/scilla-by-example.rst#L563
Example to add:
let one_msg =
fun (msg : Message) =>
let nil_msg = Nil {Message} in
Cons {Message} msg nil_msg
let two_msgs =
fun (msg1 : Message) =>
fun (msg2 : Message) =>
let msgs_tmp = one_msg msg2 in
Cons {Message} msg1 msgs_tmp
and
(* Sequential message sending starting with msg1 *)
msg1 = {_tag : ""; _recipient : owner; _amount : bal; code : got_funds_code};
msg2 = {_tag : "", _recipient : _sender; _amount : Uint128 0; code: sent_funds_code};
msgs = two_msgs msg1 msg2;
send msgs
OK, since this chapter discusses the crowdfunding contract:
Sending a message is done using the
sendinstruction, which takes a list of messages as a parameter. Since we will only ever send one message at a time in the crowdfunding contract, we define a library functionone_msgto construct a list consisting of one message:
I propose to remove the note for now and add an example for multiple messages in a separate PR.
There is an example of a multi-message send in ZRC-2 (https://github.com/Zilliqa/ZRC/blob/master/reference/FungibleToken.scilla#L240). We might want to reuse it.