Function gstd::msg::reply_with_gas

source ·
pub fn reply_with_gas<E: Encode>(
    payload: E,
    gas_limit: u64,
    value: u128,
) -> Result<MessageId>
Expand description

Same as reply, but with an explicit gas limit.

§Examples

use gstd::{exec, msg, prelude::*};

#[derive(Encode)]
#[codec(crate = gstd::codec)]
struct Reply {
    a: i32,
    b: Option<bool>,
}

#[no_mangle]
extern "C" fn handle() {
    let payload = Reply {
        a: 42,
        b: Some(true),
    };

    msg::reply_with_gas(payload, exec::gas_available() / 2, 0).expect("Unable to reply");
}