Function gstd::msg::reply_bytes_from_reservation

source ·
pub fn reply_bytes_from_reservation(
    id: ReservationId,
    payload: impl AsRef<[u8]>,
    value: u128,
) -> Result<MessageId>
Expand description

Same as reply_bytes, but it spends gas from a reservation instead of borrowing it 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 payload buffer. 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};

#[no_mangle]
extern "C" fn handle() {
    let reservation_id = ReservationId::reserve(5_000_000, 100).expect("Unable to reserve");
    msg::reply_from_reservation(reservation_id, b"PING", 0).unwrap();
}

§See also