Function gcore::msg::reply

source ·
pub fn reply(payload: &[u8], value: u128) -> Result<MessageId>
Expand description

Send a new message as a reply to the message that is currently being processed.

Some programs can reply to other programs, e.g., check another program’s state and use it as a parameter for its business logic.

This function allows sending such replies, which are similar to standard messages in terms of payload and different only in how the message processing is handled by a dedicated program function called handle_reply.

The first argument is the payload buffer. The second argument is the value to be transferred from the current program account to the reply message target account.

Reply message transactions will be posted after processing is finished, similar to the standard message send.

§Examples

use gcore::{exec, msg};

#[no_mangle]
extern "C" fn handle() {
    msg::reply(b"PING", exec::value_available()).expect("Unable to reply");
}

§See also

  • reply_push function allows forming a reply message in parts.
  • send function sends a new message to the program or user.