In this part you are going to add the transmitter functionality to your spaceship. You will learn what is necessary for sending messages and how is it possible in smart contracts.
Sound interesting? Let's go!
As you remember the message body is something like:
We left Internal message info
for future discussions and that is the time to reveal its structure.
This part of the message contains information about messages that are about to be sent from the spaceship. Several messages may be sent per your single external message.
The spaceship needs to know how to pay for each of them: either include fees to the amount mentioned in the message body or pay for it separately or for instance include all remaining spaceship balance. This information is provided by uin8 mode
. This number is in the range [0,256]. We will discuss its values in future lessons.
The message is a simple cell with a certain structure. The function send_raw_message(cell message, int mode)
is used for sending.
send_raw_message(data~load_ref(), mode);
To make it work the structure of Internal message info
should be:
Loops have the following syntax:
while(condition) {
;; body
}
do {
;; body
} until(condition)
repeat(counter) {
;; body
}
In case of while
the body is executed only if the condition is true (any int except 0), in case of until
body is executed at least one time and is repeated until the condition is equal to 0, in case of repeat
the body is executed exactly counter
times.
Make your spaceship
to work as transmitter and send messages.
while
loop that will process messages. Use number of cells stored in the msg_body_tmp to identify that there are messages to send: in_msg_tmp.slice_refs()
.~load_ref()
) and send it with send_raw_message
.