Function gstd::msg::reply_from_reservation
source · pub fn reply_from_reservation<E: Encode>(
id: ReservationId,
payload: E,
value: u128,
) -> Result<MessageId>
Expand description
Same as reply
, but it spends gas from a reservation instead of
borrowing gas from the gas limit provided with the incoming message.
The first argument is the reservation identifier ReservationId
obtained
by calling the corresponding API. The second argument is the encodable
payload. The last argument is the value to be transferred from the current
program account to the reply message target account.
§Examples
use gstd::{msg, prelude::*, ReservationId};
#[derive(Encode)]
#[codec(crate = gstd::codec)]
struct Reply {
a: i32,
b: Option<bool>,
}
#[no_mangle]
extern "C" fn handle() {
let reservation_id = ReservationId::reserve(5_000_000, 100).expect("Unable to reserve");
let payload = Reply {
a: 42,
b: Some(true),
};
msg::reply_from_reservation(reservation_id, payload, 0).unwrap();
}
§See also
send_from_reservation
function sends a new message to the program or user by using gas from a reservation.