fvm_sdk 4.8.0

Filecoin Virtual Machine actor development SDK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright 2021-2023 Protocol Labs
// SPDX-License-Identifier: Apache-2.0, MIT
use crate::sys;

/// Charge gas for the operation identified by name.
pub fn charge(name: &str, compute: u64) {
    unsafe { sys::gas::charge(name.as_ptr(), name.len() as u32, compute) }
        // can only happen if name isn't utf8, memory corruption, etc.
        .expect("failed to charge gas")
}

pub fn available() -> u64 {
    unsafe { sys::gas::available() }.expect("failed to check available gas")
}